-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.h
49 lines (44 loc) · 1.05 KB
/
parser.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
47
48
49
#ifndef _PARSER_H_
#define _PARSER_H_
#include "lexer.h"
string types[2] = {"int", "char"} ;
struct Symbol
{
string type;
string id;
Symbol(string type,string id);
Symbol();
};
//for future assignments leave it as it is
class parser
{
lexer _lexer;
vector<Symbol> symbol_table;
vector<string> tac;
vector<int> retunrIndex;
fstream tacFile;
string tempExpr = "";
bool init;
int lineNo;
int tempLine;
public:
void syntax_error();
token expect(TokenType expected_type);
parser(const char filename[]);
void readAndPrintAllInput();
void resetPointer();
void statements();
void expression();
void term();
void factor();
void condition();
void block();
void outputSymbolTable();
void outputTAC();
/*Terminal functions goes here use peek and expect*/
/*use TokenType:: for token names for example
expect(TokenType::ASSIGN); //example function call
*/
//all your parser function goes here
};
#endif