-
Notifications
You must be signed in to change notification settings - Fork 2
/
AoParser.h
94 lines (90 loc) · 2.23 KB
/
AoParser.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
#ifndef __AO_PARSER__
#define __AO_PARSER__
// This file was automatically generated by EbnfStudio; don't modify it!
#include <AoSynTree.h>
namespace Ao {
class Scanner {
public:
virtual Token next() = 0;
virtual Token peek(int offset) = 0;
};
class Parser {
public:
Parser(Scanner* s):scanner(s) {}
void RunParser();
SynTree root;
struct Error {
QString msg;
int row, col;
QString path;
Error( const QString& m, int r, int c, const QString& p):msg(m),row(r),col(c),path(p){}
};
QList<Error> errors;
protected:
void Module(SynTree*);
void ImportDecl(SynTree*);
void ImportList(SynTree*);
void DeclSeq(SynTree*);
void ConstDecl(SynTree*);
void TypeDecl(SynTree*);
void VarDecl(SynTree*);
void Assembler(SynTree*);
void ProcDecl(SynTree*);
void ProcHead(SynTree*);
void SysFlag(SynTree*);
void FormalPars(SynTree*);
void FPSection(SynTree*);
void ArrayType(SynTree*);
void RecordType(SynTree*);
void PointerType(SynTree*);
void ObjectType(SynTree*);
void ProcedureType(SynTree*);
void AliasType(SynTree*);
void Type(SynTree*);
void FieldDecl(SynTree*);
void FieldList(SynTree*);
void Body(SynTree*);
void Attributes(SynTree*);
void StatBlock(SynTree*);
void StatSeq(SynTree*);
void AssigOrCall(SynTree*);
void IfStat(SynTree*);
void CaseStat(SynTree*);
void WhileStat(SynTree*);
void RepeatStat(SynTree*);
void ForStat(SynTree*);
void LoopStat(SynTree*);
void WithStat(SynTree*);
void ReturnStat(SynTree*);
void Statement(SynTree*);
void Case(SynTree*);
void CaseLabels(SynTree*);
void ConstExpr(SynTree*);
void Expr(SynTree*);
void SimpleExpr(SynTree*);
void Term(SynTree*);
void Factor(SynTree*);
void Set(SynTree*);
void Element(SynTree*);
void Relation(SynTree*);
void MulOp(SynTree*);
void AddOp(SynTree*);
void Designator(SynTree*);
void Selector(SynTree*);
void ExprList(SynTree*);
void IdentList(SynTree*);
void Qualident(SynTree*);
void IdentDef(SynTree*);
void number(SynTree*);
protected:
Token cur;
Token la;
Scanner* scanner;
void next();
Token peek(int off);
void invalid(const char* what);
bool expect(int tt, bool pkw, const char* where);
void addTerminal(SynTree* st);
};
}
#endif // include