-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParser.hpp
More file actions
53 lines (37 loc) · 917 Bytes
/
Parser.hpp
File metadata and controls
53 lines (37 loc) · 917 Bytes
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
#ifndef ALPHA_PARSER_HPP
#define ALPHA_PARSER_HPP
#include <iostream>
#include "types.hpp"
#include "Loc.hpp"
#include "Env.hpp"
class Expr;
class StringExpr;
class Scope;
class Parser {
private:
Loc _loc;
Scope* _cur_scope = nullptr;
bool _errors = false;
Env _env;
public:
void error(const char*);
template <typename T, typename... Args>
void error(const char*, const T&, Args&& ...args);
void skipSpaces();
bool accept(char);
bool accept(const std::string&);
bool expect(char);
bool expect(const std::string&);
bool readIdentifier(std::string&);
bool readNumber(i32_t&);
Env* parse(const std::string&);
void parseFunc();
void parseScope();
void parsePrintDecl();
bool parseVarDecl(const std::string&);
StringExpr* parseStringExpr();
Expr* parseExpr();
Expr* parseTerm();
Expr* parseFactor();
};
#endif