-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.h
51 lines (50 loc) · 1.2 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
50
51
#pragma once
#include <vector>
#include "Token.h"
#include "Expr.h"
#include "Stmt.h"
class Parser
{
private:
unsigned int current = 0;
unsigned int loopDepth = 0;
std::vector<Token> tokens;
Stmt *declaration();
Stmt *varDeclaration();
void *function(std::string kind);
Stmt *classDeclaration();
Stmt *statement();
Stmt *printStatement();
Stmt *expressionStatement();
Stmt *blockStatement();
Stmt *ifStatement();
Stmt *whileStatement();
Stmt *forStatement();
Stmt *breakStatement();
Stmt *returnStatement();
Expr *expression();
Expr *assignment();
Expr *conditional();
Expr *logic_or();
Expr *logic_and();
Expr *equality();
Expr *comparison();
Expr *term();
Expr *factor();
Expr *unary();
Expr *call();
Expr *finishCall(Expr *callee);
Expr *primary();
bool match(TokenType type);
bool check(TokenType type);
Token advance();
Token peek();
Token previous();
bool isAtEnd();
bool consume(TokenType type, std::string message);
void error(Token token, std::string message);
void synchronize();
public:
Parser(std::vector<Token> tokens);
std::vector<Stmt *> parse();
};