-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.hpp
103 lines (65 loc) · 1.63 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#pragma once
#include <exception>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "lexical_parser.hpp"
#include "token.hpp"
class Parser {
private:
LexicalParser lexical;
std::ifstream file;
std::ofstream output_file;
Token token;
int line_number;
std::map<std::string, std::string> symbol_table = {
{"program", "simb_program"}, {"var", "simb_var"},
{"begin", "simb_begin"}, {"procedure", "simb_proc"},
{"end", "simb_end"}, {"write", "simb_write"},
{"read", "simb_read"}, {"while", "simb_while"},
{"do", "simb_do"}, {"to", "simb_to"},
{"integer", "simb_type"}, {"real", "simb_real"},
{"for", "simb_for"}, {"if", "simb_if"},
{"then", "simb_then"}, {"else", "simb_else"},
};
char c;
bool flag_err = false;
bool flag_lex = false;
bool match(const std::string& exp_token, bool empty = false);
void panic_mode(const std::vector<std::string>& sync_tokens);
void programa();
void corpo();
void dc();
void dc_c();
void dc_v();
void tipo_var();
void variaveis();
void dc_p();
void parametros();
void lista_par();
void corpo_p();
void dc_loc();
bool lista_arg();
void argumentos();
void pfalsa();
void cmd_ident_tail();
void comandos();
void cmd();
void condicao();
void relacao();
void expressao();
void op_un();
void outros_termos();
void op_ad();
void mais_fatores();
void op_mul();
void termo();
void fator();
void numero();
public:
Parser(const std::string& filename);
~Parser();
Token get_token();
void parse();
};