-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImpSyntaxParser.h
101 lines (82 loc) · 1.69 KB
/
ImpSyntaxParser.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
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
/*
* SyntaxParser.h
*
* Created on: 15.04.2013
* Author: urandon
*/
#ifndef IMPSYNTAXPARSER_H_
#define IMPSYNTAXPARSER_H_
#include "ImpLexicalParser.h"
class ImpSyntaxParser {
public:
ImpSyntaxParser(int fd);
virtual ~ImpSyntaxParser();
enum atom_type {
SQBRACE_LEFT, SQBRACE_RIGHT, RDBRACE_LEFT, RDBRACE_RIGHT,
FIGBRACE_LEFT, FIGBRACE_RIGHT,
ASSIGN, DOUBLEDOT, DOT_N_COMMA, COMMA,
DEFINITION,
IF, THEN, ELSE, GOTO,
BUY, SELL, PROD, BUILD, ENDTURN,
PRINT,
AND, OR, NOT,
LESS, GREATER, EQUAL,
PLUS, MINUS,
DIVISION, MUTLIPLY, MODULO,
NUMERIC, STRING, VARIABLE, FUNCTION, LABEL
};
static const char * atom_essence[];
static const int PREDEFINED_ATOMS;
struct atom {
enum atom_type type;
int id;
int line;
atom(enum atom_type type, int id, int line);
atom(const lexem & lex);
atom(const atom & mAtom);
};
struct code_t {
static const int DEFAULT_SIZE = 64;
atom ** data;
int size;
int allocated;
code_t();
~code_t();
void push(atom * mAtom);
};
private:
ImpLexicalParser lexical;
code_t code;
int lo,hi;
atom * current();
atom * next();
atom * prev();
/* language-sensitive recursive descent methods */
void Program();
void Definition();
void Code();
void Variable();
void Array();
void Variable_();
void Operator();
void Complex_operator();
void Assign_operator();
void If_opetator();
void Goto_operator();
void Game_operator();
void Print_operator();
void Labeled_operator();
void Game0();
void Game1();
void Game2();
void P_list();
void P_node();
void Expression();
void Comparator();
void Summand();
void Multiplier();
void Term();
void Func_call();
void Func_args();
};
#endif /* IMPSYNTAXPARSER_H_ */