-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathParser.hpp
More file actions
64 lines (47 loc) · 1.4 KB
/
Parser.hpp
File metadata and controls
64 lines (47 loc) · 1.4 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef __PARSER_HPP
#define __PARSER_HPP
#include "Token.hpp"
#include "Tokenizer.hpp"
#include "SymTab.hpp"
#include "ArithExpr.hpp"
#include "Statements.hpp"
#include "Functions.hpp"
#include <vector>
#include <iostream>
#include <map>
class Parser {
public:
Parser(Tokenizer &tokenizer, Functions *&_funcs) : tokenizer{tokenizer}, funcs{_funcs} {}
Statements *statements();
// Simple statements
AssignmentStatement *assignStatement(Token varName);
PrintStatement *printStatement();
ArrayOpStatement *arrayOp(Token varName);
CallStatement *callStatement(Token varName);
ExprNode *call(Token varName);
ReturnStatement *returnStatement();
// Compound statements
ForStatement *forStatement();
IfStatement *ifStatement();
Function *funcDef();
Subscription *subscription(Token varName);
std::vector<ExprNode*> array_init();
Statements *suite();
std::vector<ExprNode*> testlist();
std::vector<std::string> parameter_list();
ExprNode* array_len();
ExprNode *test();
ExprNode *or_test();
ExprNode *and_test();
ExprNode *not_test();
ExprNode *comparison();
ExprNode *arithExpr();
ExprNode *term();
ExprNode *factor();
ExprNode *atom(Token prev, int numHyphens);
private:
Tokenizer &tokenizer;
Functions *&funcs;
void die(std::string where, std::string message, Token &token);
};
#endif //__PARSER_HPP