-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.h
46 lines (36 loc) · 984 Bytes
/
parse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by user on 8/15/23.
//
#ifndef MVSHELL_PARSE_H
#define MVSHELL_PARSE_H
#include <glob.h>
#include "tokenize.h"
typedef struct Command Command;
typedef struct ParserState ParserState;
struct Command {
char* cmd;
char** args;
size_t numArgs;
Command* next; // For piped commands
char* outFile;
char* inFile;
char* appendFile;
char* errFile;
};
struct ParserState {
Token *tokens;
size_t numTokens;
size_t currentPosition;
};
void parse(ParserState *parserState);
int match(ParserState *state, Lexeme lexeme);
Token parseString(ParserState *state);
Token parseNumber(ParserState *state);
Token parseLess(ParserState *state);
Token parseGreater(ParserState *state);
Token parseOpenParens(ParserState *state);
Token parseCloseParens(ParserState *state);
Token parsePipe(ParserState *state);
Token parseWord(ParserState *state);
ParserState initializeParserState(size_t numTokens, Token *tokens);
#endif //MVSHELL_PARSE_H