-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.hpp
52 lines (40 loc) · 880 Bytes
/
parser.hpp
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
#ifndef __PARSER_H__
#define __PARSER_H__
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include "ast.hpp"
#include "global_utils.hpp"
#include "interpreter.hpp"
using namespace std;
extern map<int, string> token_names;
class Token {
public:
int type;
string value;
Token(const int &, const string &);
bool operator&(int) const;
};
class Parser {
public:
queue<Token> tokens;
AST *ast;
Parser(const string &);
bool match(int) const;
bool is_empty(void) const;
bool accept(int);
int peek_type(void) const;
string peek_value(void) const;
void next(void);
AST *factor(void);
AST *term(void);
AST *expression(void);
AST *assignment(void);
AST *multiple_assignment(void);
AST *arguments(void);
AST *call_expression(void);
AST *lambda_declaration(const string &);
AST *init(void);
};
#endif