-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ast.cf
109 lines (84 loc) · 2.57 KB
/
Ast.cf
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
104
105
106
107
108
109
entrypoints Prog;
Int. Type ::= "int" ;
Boolean. Type ::= "boolean" ;
Double. Type ::= "double" ;
Void. Type ::= "void" ;
Table. Type ::= Type [Pos];
[]. [Pos] ::= ;
(:[]). [Pos] ::= Pos ;
(:). [Pos] ::= Pos [Pos] ;
PosF. Pos ::= "[" Exp "]";
PosE. Pos ::= "[" "]";
[]. [IdentExp] ::= ;
(:[]). [IdentExp] ::= IdentExp ;
(:). [IdentExp] ::= IdentExp "," [IdentExp] ;
[]. [Func] ::= ;
(:[]). [Func] ::= Func ;
(:). [Func] ::= Func [Func] ;
[]. [Instr] ::= ;
(:[]). [Instr] ::= Instr ;
(:). [Instr] ::= Instr [Instr] ;
[]. [Arg] ::= ;
(:[]). [Arg] ::= Arg ;
(:). [Arg] ::= Arg "," [Arg] ;
ArgDecl. Arg ::= Type Ident;
[]. [Exp] ::= ;
(:[]). [Exp] ::= Exp ;
(:). [Exp] ::= Exp "," [Exp] ;
Entry. Prog ::= [Func] ;
FuncDecl. Func ::= Type Ident "(" [Arg] ")" Instr;
IBlock. Instr ::= "{" [Instr] "}";
IdentEmpty. IdentExp ::= Ident ;
IdentExp. IdentExp ::= Ident "=" Exp;
IDecl. Instr ::= Type [IdentExp] ";" ;
IRet. Instr ::= "return" Exp ";" ;
IRetEmpty. Instr ::= "return" ";" ;
IExp. Instr ::= Exp ";" ;
IIf. Instr ::= "if" "(" Exp ")" Instr;
IIfElse. Instr ::= "if" "(" Exp ")" Instr "else" Instr;
IWhile. Instr ::= "while" "(" Exp ")" Instr;
IFor. Instr ::= "for" "(" Instr Exp ";" Exp ")" Instr;
EVarSet. Exp ::= Ident "=" Exp ;
EVarSetTable. Exp ::= Ident [Pos] "=" Exp ;
EOr. Exp1 ::= Exp1 "||" Exp2 ;
EAnd. Exp2 ::= Exp2 "&&" Exp3 ;
EEq. Exp3 ::= Exp3 "==" Exp4 ;
ENEq. Exp3 ::= Exp3 "!=" Exp4 ;
ESm. Exp4 ::= Exp4 "<" Exp5 ;
EGr. Exp4 ::= Exp4 ">" Exp5 ;
EESm. Exp4 ::= Exp4 "<=" Exp5 ;
EEGr. Exp4 ::= Exp4 ">=" Exp5 ;
EAdd. Exp5 ::= Exp5 "+" Exp6 ;
ESub. Exp5 ::= Exp5 "-" Exp6 ;
EMul. Exp6 ::= Exp6 "*" Exp7 ;
EDiv. Exp6 ::= Exp6 "/" Exp7 ;
EMod. Exp6 ::= Exp6 "%" Exp7 ;
ENot. Exp7 ::= "!" Exp7 ;
EPlus. Exp7 ::= "+" Exp7 ;
EMinus. Exp7 ::= "-" Exp7 ;
EPostPlus. Exp7 ::= Exp7 "++" ;
EPostMinus. Exp7 ::= Exp7 "--" ;
EPrePlus. Exp7 ::= "++" Exp7 ;
EPreMinus. Exp7 ::= "--" Exp7 ;
_. Exp7 ::= "(" Exp ")" ;
EVarPos. Exp7 ::= Ident [Pos];
EVar. Exp7 ::= Ident ;
ECall. Exp7 ::= Ident "(" [Exp] ")" ;
EDouble. Exp7 ::= Double ;
EInt. Exp7 ::= Integer ;
ETrue. Exp7 ::= "true" ;
EFalse. Exp7 ::= "false" ;
EStr. Exp7 ::= String ;
EToInt. Exp7 ::= "(" "int" ")" Exp7 ;
EToBool. Exp7 ::= "(" "boolean" ")" Exp7 ;
EToDouble. Exp7 ::= "(" "double" ")" Exp7 ;
_. Exp6 ::= Exp7 ;
_. Exp5 ::= Exp6 ;
_. Exp4 ::= Exp5 ;
_. Exp3 ::= Exp4 ;
_. Exp2 ::= Exp3 ;
_. Exp1 ::= Exp2 ;
_. Exp ::= Exp1 ;
comment "/*" "*/";
comment "//";
comment "#";