-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixedgrammar.grm
190 lines (122 loc) · 4.74 KB
/
fixedgrammar.grm
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<START> ::= <prog> 'eof'
<addOp> ::= '+'
<addOp> ::= '-'
<addOp> ::= 'or'
<aParams> ::= <expr> <rept-aParams1>
<aParams> ::= EPSILON
<aParamsTail> ::= ',' <expr>
<arithExpr> ::= <term> <rightrec-arithExpr>
<arraySize> ::= '[' <arraySize2>
<arraySize2> ::= 'intlit' ']'
<arraySize2> ::= ']'
<assignOp> ::= '='
<expr> ::= <arithExpr> <expr2>
<expr2> ::= <relOp> <arithExpr>
<expr2> ::= EPSILON
<factor> ::= 'id' <factor2> <rept-var-or-funcCall>
<factor> ::= 'intlit'
<factor> ::= 'floatlit'
<factor> ::= '(' <arithExpr> ')'
<factor> ::= 'not' <factor>
<factor> ::= <sign> <factor>
<factor2> ::= '(' <aParams> ')'
<factor2> ::= <rept-idnest1>
<fParams> ::= 'id' ':' <type> <rept-fParams3> <rept-fParams4>
<fParams> ::= EPSILON
<fParamsTail> ::= ',' 'id' ':' <type> <rept-fParamsTail4>
<funcBody> ::= '{' <rept-funcBody1> '}'
<funcDecl> ::= <funcHead> ';'
<funcDef> ::= <funcHead> <funcBody>
<funcHead> ::= 'func' 'id' '(' <fParams> ')' 'arrow' <returnType>
<statement> ::= 'id' <statement-Id-nest> ';'
<statement> ::= 'if' '(' <relExpr> ')' 'then' <statBlock> 'else' <statBlock> ';'
<statement> ::= 'while' '(' <relExpr> ')' <statBlock> ';'
<statement> ::= 'read' '(' <variable> ')' ';'
<statement> ::= 'write' '(' <expr> ')' ';'
<statement> ::= 'return' '(' <expr> ')' ';'
<statement-Id-nest> ::= '.' 'id' <statement-Id-nest>
<statement-Id-nest> ::= '(' <aParams> ')' <statement-Id-nest2>
<statement-Id-nest> ::= <indice> <rept-idnest1> <statement-Id-nest3>
<statement-Id-nest> ::= <assignOp> <expr>
<statement-Id-nest2> ::= EPSILON
<statement-Id-nest2> ::= '.' 'id' <statement-Id-nest>
<statement-Id-nest3> ::= <assignOp> <expr>
<statement-Id-nest3> ::= '.' 'id' <statement-Id-nest>
<rept-idnest1> ::= <indice> <rept-idnest1>
<rept-idnest1> ::= EPSILON
<rept-var-or-funcCall> ::= <idNest> <rept-var-or-funcCall>
<rept-var-or-funcCall> ::= EPSILON
<idNest> ::= '.' 'id' <idNest2>
<idNest2> ::= '(' <aParams> ')'
<idNest2> ::= <rept-idnest1>
<implDef> ::= 'impl' 'id' '{' <rept-implDef3> '}'
<indice> ::= '[' <arithExpr> ']'
<memberDecl> ::= <funcDecl>
<memberDecl> ::= <varDecl>
<multOp> ::= '*'
<multOp> ::= '/'
<multOp> ::= 'and'
<opt-structDecl2> ::= 'inherits' 'id' <rept-opt-structDecl22>
<opt-structDecl2> ::= EPSILON
<prog> ::= <rept-prog0>
<relExpr> ::= <arithExpr> <relOp> <arithExpr>
<relOp> ::= 'eq'
<relOp> ::= 'neq'
<relOp> ::= 'lt'
<relOp> ::= 'gt'
<relOp> ::= 'leq'
<relOp> ::= 'geq'
<rept-aParams1> ::= <aParamsTail> <rept-aParams1>
<rept-aParams1> ::= EPSILON
<rept-fParams3> ::= <arraySize> <rept-fParams3>
<rept-fParams3> ::= EPSILON
<rept-fParams4> ::= <fParamsTail> <rept-fParams4>
<rept-fParams4> ::= EPSILON
<rept-fParamsTail4> ::= <arraySize> <rept-fParamsTail4>
<rept-fParamsTail4> ::= EPSILON
<rept-funcBody1> ::= <varDeclOrStat> <rept-funcBody1>
<rept-funcBody1> ::= EPSILON
<rept-implDef3> ::= <funcDef> <rept-implDef3>
<rept-implDef3> ::= EPSILON
<rept-opt-structDecl22> ::= ',' 'id' <rept-opt-structDecl22>
<rept-opt-structDecl22> ::= EPSILON
<rept-prog0> ::= <structOrImplOrfunc> <rept-prog0>
<rept-prog0> ::= EPSILON
<rept-statBlock1> ::= <statement> <rept-statBlock1>
<rept-statBlock1> ::= EPSILON
<rept-structDecl4> ::= <visibility> <memberDecl> <rept-structDecl4>
<rept-structDecl4> ::= EPSILON
<rept-varDecl4> ::= <arraySize> <rept-varDecl4>
<rept-varDecl4> ::= EPSILON
<returnType> ::= <type>
<returnType> ::= 'void'
<rightrec-arithExpr> ::= EPSILON
<rightrec-arithExpr> ::= <addOp> <term> <rightrec-arithExpr>
<rightRecTerm> ::= EPSILON
<rightRecTerm> ::= <multOp> <factor> <rightRecTerm>
<sign> ::= '+'
<sign> ::= '-'
<statBlock> ::= '{' <rept-statBlock1> '}'
<statBlock> ::= <statement>
<statBlock> ::= EPSILON
<structDecl> ::= 'struct' 'id' <opt-structDecl2> '{' <rept-structDecl4> '}' ';'
<structOrImplOrfunc> ::= <structDecl>
<structOrImplOrfunc> ::= <implDef>
<structOrImplOrfunc> ::= <funcDef>
<term> ::= <factor> <rightRecTerm>
<type> ::= 'integer'
<type> ::= 'float'
<type> ::= 'id'
<varDecl> ::= 'let' 'id' ':' <type> <rept-varDecl4> ';'
<varDeclOrStat> ::= <varDecl>
<varDeclOrStat> ::= <statement>
<variable> ::= 'id' <variable2>
<variable2> ::= <rept-idnest1> <rept-variable>
<variable2> ::= '(' <aParams> ')' <var-idNest>
<rept-variable> ::= <var-idNest> <rept-variable>
<rept-variable> ::= EPSILON
<var-idNest> ::= '.' 'id' <var-idNest2>
<var-idNest2> ::= '(' <aParams> ')' <var-idNest>
<var-idNest2> ::= <rept-idnest1>
<visibility> ::= 'public'
<visibility> ::= 'private'