-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.h
35 lines (27 loc) · 928 Bytes
/
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
#ifndef PARSER_H
#define PARSER_H
#include <bits/stdc++.h>
#include "statement.h"
#include "tokenizer.h"
#include "exp.h"
//think parser as a factory class of statement
class Parser
{
public:
Parser();
~Parser();
Statement *getStatement(std::string &stmt);
private:
Tokenizer* tk;
Statement *parseImmediate(std::vector<Token> &tokens);
Statement *parseStatement(std::vector<Token> &tokens,std::string stmt);
Statement *parseLet(std::vector<Token> &tokens,std::string stmt);
Statement *parsePrint(std::vector<Token> &tokens,std::string stmt);
Statement *parseInput(std::vector<Token> &tokens);
Statement *parseIf(std::vector<Token> &tokens);
Statement *parseGoto(std::vector<Token> &tokens);
Statement *parseEnd(std::vector<Token> &tokens);
Statement *parseRem(std::vector<Token> &tokens);
Expression *parseExp(std::vector<Token> &expTokens);
};
#endif // PARSER_H