42 lines
824 B
C
42 lines
824 B
C
#ifndef SCANNER_H
|
|
#define SCANNER_H
|
|
|
|
#define INITIAL_STRING_SIZE 10
|
|
|
|
// This enum denotes what type of variable a token is.
|
|
enum Type {
|
|
EXECUTABLE, // a command in either $CWD or $PATH
|
|
OPTION, // any options to pass to an executable or builtin
|
|
COMPOSITION, // '&&', '||', ';', '\n'
|
|
BUILTIN, // one of a few pre-defined builtin executables
|
|
PIPELINE, // '|'
|
|
REDIRECT, // '<' or '>'
|
|
BACKGROUND, // '&'
|
|
FILENAME // a file (for redirection)
|
|
};
|
|
|
|
typedef struct ListNode *List;
|
|
|
|
typedef struct ListNode {
|
|
char *t;
|
|
enum Type type;
|
|
List next;
|
|
} ListNode;
|
|
|
|
|
|
#if EXT_PROMPT
|
|
char *readInputLine(char const *prompt);
|
|
#else
|
|
char *readInputLine();
|
|
#endif
|
|
|
|
List getTokenList(char *s);
|
|
|
|
bool isEmpty(List l);
|
|
|
|
void printList(List l);
|
|
|
|
void freeTokenList(List l);
|
|
|
|
#endif
|