source: applications/trunk/LFC/lfc.ag @ 4139

Last change on this file since 4139 was 3811, checked in by orlov, 12 years ago
  • UNDEFINED can't be concatenated with anything.
  • Property svn:eol-style set to native
File size: 4.6 KB
Line 
1
2Nullable nonterminals:
3
4  (arg_list | arg_list_rest | concept_list_rest | equation_rest | exp_concat |
5  exp_concat_or_where | exp_var_or_func | pat_concat | pattern_list_rest | program_rest |
6  varassign_rest | variable_dec_rest | variable_list_rest)
7
8
9The starters of nonterminals:
10
11program ->
12  (DEC)
13program_rest ->
14  (DEC)
15function_dec ->
16  (DEC)
17var_dec_and_func_def ->
18  (DEF | VAR)
19variable_dec ->
20  (VAR)
21vars_decl ->
22  (IDENTIFIER)
23variable_dec_rest ->
24  (IDENTIFIER)
25variable_list ->
26  (IDENTIFIER)
27variable_list_rest ->
28  (COMMA)
29definition ->
30  (DEF)
31equation ->
32  (IDENTIFIER)
33equation_rest ->
34  (IDENTIFIER)
35pattern_list ->
36  (IDENTIFIER | STRING)
37pattern ->
38  (IDENTIFIER | STRING)
39pat_concat ->
40  (CONCAT)
41pattern_list_rest ->
42  (COMMA)
43function_type ->
44  (IDENTIFIER)
45concept_list_rest ->
46  (ASTERISK)
47concept_name ->
48  (IDENTIFIER)
49funname ->
50  (IDENTIFIER)
51variable ->
52  (IDENTIFIER)
53exp ->
54  (IDENTIFIER | IF | LPAR | STRING)
55exp_with_where ->
56  (IDENTIFIER | IF | LPAR | STRING)
57exp_with_where_or_undef ->
58  (IDENTIFIER | IF | LPAR | STRING | UNDEFINED)
59exp_var_or_func ->
60  (LPAR)
61arg_list ->
62  (IDENTIFIER | IF | LPAR | STRING)
63arg_list_rest ->
64  (COMMA)
65exp_concat ->
66  (CONCAT)
67exp_concat_or_where ->
68  (CONCAT | WHERE)
69varassign_list ->
70  (IDENTIFIER)
71varassign_rest ->
72  (COMMA)
73
74
75The followers of nullable nonterminals:
76
77program_rest ->
78  ($END)
79variable_dec_rest ->
80  (DEF)
81variable_list_rest ->
82  (COLON)
83equation_rest ->
84  ($END | DEC)
85pat_concat ->
86  (COMMA | RPAR)
87pattern_list_rest ->
88  (RPAR)
89concept_list_rest ->
90  (TO)
91exp_var_or_func ->
92  (COMMA | CONCAT | ELSE | RPAR | SC |
93  THEN | WHERE)
94arg_list ->
95  (RPAR)
96arg_list_rest ->
97  (RPAR)
98exp_concat ->
99  (COMMA | ELSE | RPAR | SC | THEN)
100exp_concat_or_where ->
101  (ELSE | RPAR | SC | THEN)
102varassign_rest ->
103  (ELSE | RPAR | SC | THEN)
104
105
106*** Annotated grammar ***
107
108program
109: (DEC)
110     function_dec var_dec_and_func_def #program_rest
111;
112
113#program_rest
114: ($END)
115     /* empty */
116| (DEC)
117     program
118;
119
120function_dec
121: (DEC)
122     DEC funname COLON function_type SC
123;
124
125var_dec_and_func_def
126: (VAR)
127     variable_dec definition
128| (DEF)
129     definition
130;
131
132variable_dec
133: (VAR)
134     VAR vars_decl #variable_dec_rest
135;
136
137vars_decl
138: (IDENTIFIER)
139     variable_list COLON concept_name SC
140;
141
142#variable_dec_rest
143: (DEF)
144     /* empty */
145| (IDENTIFIER)
146     vars_decl #variable_dec_rest
147;
148
149variable_list
150: (IDENTIFIER)
151     variable #variable_list_rest
152;
153
154#variable_list_rest
155: (COLON)
156     /* empty */
157| (COMMA)
158     COMMA variable #variable_list_rest
159;
160
161definition
162: (DEF)
163     DEF equation #equation_rest
164;
165
166equation
167: (IDENTIFIER)
168     funname LPAR pattern_list RPAR EQ exp_with_where_or_undef SC
169;
170
171#equation_rest
172: ($END | DEC)
173     /* empty */
174| (IDENTIFIER)
175     equation #equation_rest
176;
177
178pattern_list
179: (IDENTIFIER | STRING)
180     pattern #pattern_list_rest
181;
182
183pattern
184: (STRING)
185     STRING #pat_concat
186| (IDENTIFIER)
187     variable #pat_concat
188;
189
190#pat_concat
191: (COMMA | RPAR)
192     /* empty */
193| (CONCAT)
194     CONCAT pattern
195;
196
197#pattern_list_rest
198: (RPAR)
199     /* empty */
200| (COMMA)
201     COMMA pattern #pattern_list_rest
202;
203
204function_type
205: (IDENTIFIER)
206     concept_name #concept_list_rest TO concept_name
207;
208
209#concept_list_rest
210: (TO)
211     /* empty */
212| (ASTERISK)
213     ASTERISK concept_name #concept_list_rest
214;
215
216concept_name
217: (IDENTIFIER)
218     IDENTIFIER
219;
220
221funname
222: (IDENTIFIER)
223     IDENTIFIER
224;
225
226variable
227: (IDENTIFIER)
228     IDENTIFIER
229;
230
231exp
232: (STRING)
233     STRING #exp_concat
234| (IDENTIFIER)
235     IDENTIFIER #exp_var_or_func #exp_concat
236| (LPAR)
237     LPAR exp_with_where RPAR #exp_concat
238| (IF)
239     IF exp THEN exp ELSE exp
240;
241
242exp_with_where
243: (STRING)
244     STRING #exp_concat_or_where
245| (IDENTIFIER)
246     IDENTIFIER #exp_var_or_func #exp_concat_or_where
247| (LPAR)
248     LPAR exp_with_where RPAR #exp_concat_or_where
249| (IF)
250     IF exp_with_where THEN exp_with_where ELSE exp_with_where
251;
252
253exp_with_where_or_undef
254: (UNDEFINED)
255     UNDEFINED
256| (IDENTIFIER | IF | LPAR | STRING)
257     exp_with_where
258;
259
260#exp_var_or_func
261: (COMMA | CONCAT | ELSE | RPAR | SC |
262  THEN | WHERE)
263     /* empty */
264| (LPAR)
265     LPAR #arg_list RPAR
266;
267
268#arg_list
269: (RPAR)
270     /* empty */
271| (IDENTIFIER | IF | LPAR | STRING)
272     exp #arg_list_rest
273;
274
275#arg_list_rest
276: (RPAR)
277     /* empty */
278| (COMMA)
279     COMMA exp #arg_list_rest
280;
281
282#exp_concat
283: (COMMA | ELSE | RPAR | SC | THEN)
284     /* empty */
285| (CONCAT)
286     CONCAT exp
287;
288
289#exp_concat_or_where
290: (ELSE | RPAR | SC | THEN)
291     /* empty */
292| (CONCAT)
293     CONCAT exp_with_where
294| (WHERE)
295     WHERE varassign_list
296;
297
298varassign_list
299: (IDENTIFIER)
300     variable EQ exp #varassign_rest
301;
302
303#varassign_rest
304: (ELSE | RPAR | SC | THEN)
305     /* empty */
306| (COMMA)
307     COMMA varassign_list
308;
309
Note: See TracBrowser for help on using the repository browser.