Mercurial > ~dholland > hg > ag > index.cgi
comparison tests/agcl/oldagsrc/t4xa.syn @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 [nest comments] | |
2 { | |
3 /* | |
4 AnaGram Syntax Analyzer. Copyright (c) Jerome T. Holland, 1989, 1990. | |
5 All Rights Reserved. | |
6 */ | |
7 #define PARSE_PROC_DECLARATION parse() | |
8 #define STACK_DEPTH 100 | |
9 #define NEXT_TOKEN next_token_11() | |
10 /* #define GET_TOKEN next_token_11() */ | |
11 #define GET_TOKEN tkn = tv = (unsigned char) *input_pointer; | |
12 #define ADVANCE_POINTER input_pointer++ | |
13 #define TOKEN tkn | |
14 #define TOKEN_VALUE tv | |
15 #define PARSE_STACK_OVERFLOW\ | |
16 {fprintf(stderr,"parse stack overflow\n");myabort();} | |
17 /* #define ERROR {syntax_error(); /* return 0; */} */ | |
18 #define ERROR {if (TOKEN == eof_tkn) return 0;} | |
19 #define DIAGNOSE diagnose_syntax_error | |
20 #define LINE lines | |
21 #define COLUMN col | |
22 #define TRACK_COLUMN | |
23 #define TRACK_LINE | |
24 #define STACK_COLUMN | |
25 #define STACK_LINE | |
26 #define POINTER input_pointer | |
27 #define BACKTRACK | |
28 #define RESYNCH_EOF eof_tkn | |
29 #define RESYNCH | |
30 } | |
31 | |
32 { | |
33 #include "assert.h" | |
34 #include <stdio.h> | |
35 #include <dos.h> | |
36 #include <string.h> | |
37 #include "data.h" | |
38 #include "arrays.h" | |
39 #include "trees.h" | |
40 #include "myalloc.h" | |
41 #include "stk.h" | |
42 #include "pgg18.h" | |
43 | |
44 typedef enum {PGG18_TOKENS} pgg18_tkns; | |
45 | |
46 extern unsigned char tkn; | |
47 extern long tv; | |
48 | |
49 extern string_dict *tkn_dict; | |
50 extern string_dict *param_dict; | |
51 extern string_dict *cast_dict; | |
52 extern tsd *form_table; | |
53 extern tsd *dummy_token_table; | |
54 extern tsd *reducing_proc_table; | |
55 extern tsd *form_length_table; | |
56 extern tsd *bnf_table; | |
57 extern tsd *primary_token_table; | |
58 extern tsd *cast_table; /* index of cast list */ | |
59 extern tsd *cast_list; /* lists cast id's */ | |
60 | |
61 extern tsd *form_base; | |
62 extern tsd *form_item; | |
63 extern tsd *form_length; | |
64 | |
65 extern FILE *list; | |
66 extern char *input_pointer; | |
67 extern char *input_base; | |
68 extern char *string_base; | |
69 | |
70 extern int partition_required; | |
71 | |
72 node val(int); | |
73 char *build_string(); | |
74 int *build_list(); | |
75 extern int syntax_error_flag; | |
76 | |
77 } | |
78 | |
79 character set = 0.255\ | |
80 blank = ' ', | |
81 comma = ',' ! | |
82 digit = '0-9'@ | |
83 newline = 012 # | |
84 carriage return# = 015 | |
85 letter = 'a-z' 'A-Z' + '_' | |
86 letter = 'a-z' + 'A-Z + '_' | |
87 letter = 'a+z' + 'A-Z + '_' | |
88 tilde = '~" | |
89 semicolon = ";' | |
90 star = '*' bar = '|' | |
91 colon = ':' | |
92 lparen = '(' | |
93 rparen = ')' | |
94 lbrace = '{' | |
95 right brace = '}' | |
96 squote = ''' | |
97 dquote = '"' | |
98 backslash = '\' | |
99 slash = '/' | |
100 dollar = '$' | |
101 dot = '.' | |
102 lbrack = '[' | |
103 rbrack = ']' | |
104 tab = 9 | |
105 minus = '-' | |
106 ampersand = '&' | |
107 plus = '+' | |
108 | |
109 eof = 0 + 26 + | |
110 | |
111 anything = ~eof | |
112 | |
113 simple c char = ~(star + '{' + '}' + squote + dquote + slash + eof | |
114 | |
115 c literal elem = ~(squote + dquote + backslash + eof) | |
116 | |
117 [auto resynch] | |
118 | |
119 c char //c char represents the content of embedded c | |
120 -> simple c char | |
121 -> slash, ~star & ~eof | |
122 -> star, ~slash & ~eof | |
123 -> c comment | |
124 -> '{', c text, '}' | |
125 -> c literal char, squote | |
126 -> c literal string, dquote | |
127 | |
128 head list names //left hand side of productions | |
129 -> name, grammar flag = head_list_1(int); | |
130 -> head list names, comma, space, name, grammar flag = head_list_2(int); | |
131 | |
132 *head list | |
133 -> head list names | |
134 -> head list names, '[', simple space, token parameters, ']', blanks | |
135 | |
136 | |
137 token parameters, | |
138 -> token parameter, [comma, simple space, token parameter]... | |
139 -> error, ')' | |
140 | |
141 token parameter | |
142 -> name =gp1; | |
143 -> name, '=', simple space, name =gp2; | |
144 -> tilde, simple space, name =gp1; | |
145 -> name, '=', simple space, tilde, simple space, name =gp2; | |
146 -> name, '=', simple space, string =gp3; | |
147 -> name, '=', simple space, number =gp1; | |
148 | |
149 grammar flag $$ | |
150 -> = flag1; | |
151 -> dollar, blanks = flag2; | |
152 | |
153 | |
154 name | |
155 -> {letter = scs(char);}, | |
156 [(letter + digit) = acs(char); | mid line white = atbc;... | |
157 | |
158 blanks -> | blanks, mid line white | |
159 | |
160 mid line white | |
161 -> blank | |
162 -> tab | |
163 -> c comment | |
164 | |
165 space -> | space, white | |
166 | |
167 simple space | |
168 -> blanks, comment, blanks] | |
169 | |
170 white | |
171 -> mid line white | |
172 -> comment | |
173 | |
174 end of line | |
175 -> comment, space | |
176 | |
177 comment -> [';' [~carriage return & ~newline &~eof]...], | |
178 carriage return?, newline | |
179 /* | |
180 comment -> carriage return?, newline | |
181 | |
182 continuation -> | end of line | |
183 */ | |
184 | |
185 continuation = [comment, mid line white?..] | |
186 | |
187 decimal number | |
188 -> '1-9' = number_1(int); | |
189 -> decimal number, '0-9' = number_2(int,int); | |
190 | |
191 octal number | |
192 -> '0' = number_1(int); | |
193 -> octal number, '0-' =number_3(int,int); | |
194 | |
195 hex number | |
196 -> '0', 'x' + 'X' = number_1(int); | |
197 -> hex number, '0-9' =number_4(int,int); | |
198 -> hex number, 'A-F' =number_5(int,int); | |
199 -> hex number, 'a-f' =number_6(int,int); | |
200 | |
201 number | |
202 -> decimal number | |
203 -> octal number | |
204 -> hex number | |
205 | |
206 range | |
207 -> squote, anything, minus, anything, squote = range(unsigned, unsigned); | |
208 -> squote, anything, dot, anything, squote = range; | |
209 -> number, blanks, dot, simple space, number = range; | |
210 | |
211 simple set | |
212 -> range, blanks = node ss3; | |
213 -> squote, anything, squote, blanks = node ss1(unsigned); | |
214 -> number, blanks = node ss1(unsigned); | |
215 -> name = node ss2; | |
216 -> '(', simple space, union, continuation, ')', blanks = long pass(long); | |
217 | |
218 negation | |
219 -> simple set | |
220 -> tilde, simple space, negation node make_tilde_node(node) | |
221 | |
222 form element | |
223 -> union =form_element_1(node); | |
224 -> virtual production | |
225 | |
226 | |
227 vp form element | |
228 -> name =form_element_2//; | |
229 // -> '(', simple space, union, continuation, ')',blanks =form_element_1(node); | |
230 | |
231 | |
232 intersection | |
233 -> negation | |
234 -> intersection, ampersand, simple space, negation = node make_and_node(node,node); | |
235 | |
236 union | |
237 -> intersection | |
238 -> union, plus, simple space, intersection = node make_or_node(node,node); | |
239 -> union, minus, simple space, intersection = node make_minus_node(node,node); | |
240 | |
241 complete definition | |
242 -> definition, end of line | |
243 | |
244 definition | |
245 -> name, '=', simple space, union =definition_1(node) ; | |
246 -> name, '=', simple space, virtual production =definition_2(int) ; | |
247 | |
248 parameter flag | |
249 -> = flag1; | |
250 -> star, simple space = flag2; | |
251 | |
252 string | |
253 -> {dquote = ics;}, [~dquote & ~eof = acs]..., dquote, blanks | |
254 | |
255 form body | |
256 -> parameter flag, form element, parameter name = fb1(int, int, int); | |
257 -> form body, comma, simple space, parameter flag, | |
258 form element, parameter name =fb2(int,int,int); | |
259 | |
260 parameter name | |
261 -> = pn1; | |
262 -> '\', simple space, c name = pn2; | |
263 { | |
264 fb1(int flag, int element, int name) { | |
265 pf1(flag, element,name); | |
266 | |
267 } | |
268 | |
269 fb2(int flag, int element, int name) { | |
270 pf2(flag, element,name); | |
271 } | |
272 pn1() {return 0;} | |
273 pn2() {ids(cvar_dict); return fis();} | |
274 | |
275 } | |
276 | |
277 parametrized form | |
278 -> proper form, '[', simple space, form parameters, ']', blanks | |
279 | |
280 parametrized vp form | |
281 -> proper vp form, '[', simple space, form parameters, ']', blanks | |
282 | |
283 form parameters | |
284 -> form parameter, [comma, simple space, form parameter]... | |
285 | |
286 form parameter | |
287 -> name =gp1; | |
288 -> tilde, simple space, name =gp1; | |
289 -> name, '=', simple space, tilde, simple space, name =gp2; | |
290 -> name, '=', simple space, name =gp2; | |
291 -> name, '=', simple space, string =gp3; | |
292 -> name, '=', simple space, number =gp1; | |
293 | |
294 form | |
295 -> =form1; | |
296 -> form body =form2; | |
297 | |
298 null form -> =form1; | |
299 | |
300 proper form | |
301 -> form body =form2; | |
302 | |
303 vp form | |
304 -> =iws; | |
305 -> form body | |
306 | |
307 proper vp form | |
308 -> form body | |
309 | |
310 | |
311 proper vp form spec | |
312 -> proper vp form =form_spec_4; | |
313 -> proper vp form, '=', simple space, proc spec =form_spec_3(int); | |
314 -> parametrized vp form =form_spec_4; | |
315 -> parametrized vp form, | |
316 ':', simple space, proc spec =form_spec_3(int); | |
317 | |
318 mid line action | |
319 -> '!', simple space, proc spec =mid_line(int); | |
320 | |
321 form spec | |
322 /* | |
323 -> form | |
324 */ | |
325 -> null form | |
326 -> proper form | |
327 -> null form, ':', simple space, proc spec =form_spec_2(int,int); | |
328 -> proper form, ':', simple space, proc spec =form_spec_2(int,int); | |
329 -> parametrized form | |
330 -> parametrized form, | |
331 ':, simple space, proc spec =form_spec_2(int,int); | |
332 | |
333 proper form spec | |
334 -> proper form | |
335 -> proper form, ':', simple space, proc spec =form_spec_2(int,int); | |
336 -> parametrized form | |
337 -> parametrized form, | |
338 :', simple space, proc spec =form_spec_2(int,int); | |
339 | |
340 proc spec | |
341 -> proc name | |
342 -> proc name, '(', simple space, ')', blanks | |
343 -> proc name, '(', simple space, casts, ')', blanks = proc_spec_3(int); | |
344 | |
345 -> proc name, '(', simple space, casts, ')', blanks, embedded c | |
346 -> proc cast, embedded c =proc_spec_4(int); | |
347 | |
348 proc cast | |
349 -> =pc_1; | |
350 -> '(, simple space, cast, ')', simple space = pc_2; | |
351 | |
352 { | |
353 pc_1() {return 0;} | |
354 pc_2() { ids(cast_dict); return fis();} | |
355 } | |
356 | |
357 /***/ | |
358 /* | |
359 cast | |
360 -> simple name | |
361 -> simple name, mid line white... | |
362 -> simple name, star =new_cast_1; | |
363 -> simple name, mid line white..., star =new_cast_1; | |
364 -> simple name, mid line white..., cast =new_cast_2; | |
365 -> simple name, mid line white..., star, cast =new_cast_3; | |
366 -> simple name, star, cast =new_cast_3; | |
367 | |
368 real space | |
369 -> comment, simple space | |
370 -> mid line white... | |
371 | |
372 cast | |
373 -> simple name | |
374 -> simple name, real space | |
375 -> simple name, star =new_cast_1; | |
376 -> simple name, real space, star =new_cast_1; | |
377 -> simple name, real space, cast =new_cast_2; | |
378 -> simple name, real space, star, cast =new_cast_3; | |
379 -> simple name, star, cast =new_cast_3; | |
380 { | |
381 new_cast_1() { | |
382 ass(" *"); | |
383 } | |
384 new_cast_2() { | |
385 its(' ',0); | |
386 concat_string(); | |
387 } | |
388 new_cast_3() { | |
389 its('*',0); | |
390 new_cast_2(); | |
391 } | |
392 } | |
393 | |
394 proc name | |
395 -> partial proc name = new_proc_name_4(int); | |
396 | |
397 partial proc name | |
398 -> simple name =new_proc_name_1; | |
399 -> simple name, mid line white... =new_proc_name_1; | |
400 -> simple name, mid line white..., partial proc name = new_proc_name_2(int); | |
401 -> simple name, mid line white..., star, mid line white..., | |
402 partial proc name = new_proc_name_3(int); | |
403 -> simple name, star, mid line white..., partial proc name = new_proc_name_3; | |
404 { | |
405 new_proc_name_4(int name) { | |
406 ids(cast_dict); | |
407 check_size(map_proc_name, name, 3*name/2); | |
408 map_proc_name[name].cast = fis(); | |
409 return name; | |
410 } | |
411 | |
412 new_proc_name_1() { | |
413 int name; | |
414 | |
415 ids(proc_dict); | |
416 name = fis(); | |
417 ics(); | |
418 return name; | |
419 } | |
420 new_proc_name_2(int name) { | |
421 its(' ',0); | |
422 concat_string(); | |
423 return name; | |
424 } | |
425 new_proc_name_3(int name) { | |
426 its('*',0); | |
427 return new_proc_name_2(name); | |
428 } | |
429 } | |
430 | |
431 casts | |
432 -> cast = new_cast_spec_1; | |
433 -> casts, comma, simple space, cast = new_cast_spec_2; | |
434 | |
435 { | |
436 new_cast_spec_1() { | |
437 ids(cast_dict); | |
438 sws(fis()); | |
439 } | |
440 new_cast_spec_2() { | |
441 ids(cast_dict); | |
442 aws(fis()); | |
443 } | |
444 | |
445 } | |
446 | |
447 /*****/ | |
448 | |
449 | |
450 /* | |
451 proc name | |
452 -> proc cast, c name :proc_name_1 | |
453 -> c name :proc_name_2 | |
454 */ | |
455 simple name | |
456 -> letter =scs(char); | |
457 -> simple name, letter =acs(char); | |
458 -> simple name, digit =acs(char); | |
459 | |
460 c name | |
461 -> simple name | |
462 -> c name, blank | |
463 /* | |
464 star cast | |
465 -> c name, star =cast_1; | |
466 -> star cast, blank | |
467 -> star cast, star = cast_2; | |
468 | |
469 cast | |
470 -> c name | |
471 -> star cast | |
472 | |
473 proc cast | |
474 -> c name, blank | |
475 -> star cast | |
476 | |
477 cast spec | |
478 -> cast =cast_spec_1; | |
479 -> proc cast, c name =cast_spec_2; | |
480 | |
481 casts | |
482 -> *cast spec =sws(int); | |
483 -> casts, comma, simple space, *cast spec =aws(int); | |
484 */ | |
485 | |
486 form specs | |
487 -> form spec =sws(int); | |
488 -> form specs, bar, simple space, proper form spec =aws(int); | |
489 | |
490 proper form specs | |
491 -> proper form spec =sws(int); | |
492 -> proper form specs, bar, simple space, proper form spec =aws(int); | |
493 | |
494 vp form specs | |
495 -> proper vp form spec =sws; | |
496 -> vp form specs, bar, simple space, proper vp form spec =aws; | |
497 | |
498 statement | |
499 -> complete production =production(int); | |
500 -> complete definition | |
501 -> complete embedded c | |
502 -> complete precedence grammar | |
503 -> complete global parameter declaration | |
504 | |
505 unterminated statement | |
506 -> | |
507 -> production =production(int); | |
508 -> definition | |
509 -> embedded c | |
510 -> precedence grammar | |
511 -> global parameter declaration | |
512 | |
513 complete precedence grammar | |
514 -> precedence grammar, end of line | |
515 | |
516 complete global parameter declaration | |
517 -> global parameter declaration, end of line | |
518 | |
519 global parameter declaration | |
520 -> '[', simple space, global parameters, ']', blanks | |
521 | |
522 global parameters | |
523 -> global parameter, [comma, simple space, global parameter]... | |
524 | |
525 global parameter | |
526 -> name =gp1; | |
527 -> tilde, simple space, name =gp1; | |
528 -> name, '=', simple space, tilde, simple space, name =gp2; | |
529 -> name, '=', simple space, name =gp2; | |
530 -> name, '=', simple space, string =gp3; | |
531 -> name, '=', simple space, number =gp1; | |
532 | |
533 { | |
534 gp1() { ids(param_dict); return fis();} | |
535 gp2() { ids(param_dict);fis(); ids(param_dict); fis();} | |
536 gp3() { rcs(); ids(param_dict); fis();} | |
537 } | |
538 | |
539 | |
540 precedence grammar | |
541 -> pr_header, end of line?, | |
542 '{', levels, end of line?, '}' = build_pr_grmr; | |
543 | |
544 pr_header | |
545 -> "%pg", simple space, name, "->", simple space, name =init_prec_grmr; | |
546 | |
547 { | |
548 int pr_gram; | |
549 int pr_gram_base; | |
550 int pr_gram_levels; | |
551 | |
552 typedef enum {la_op, ra_op, pr_op, su_op} op_type; | |
553 | |
554 init_prec_grmr() { | |
555 token_name(); | |
556 pr_gram_base = fis(); | |
557 token_name(); | |
558 pr_gram = fis(); | |
559 pr_gram_levels = 0; | |
560 } | |
561 | |
562 build_pr_grmr() { | |
563 int *tn, t, i; | |
564 | |
565 tn = allocate(pr_gram_levels + 1, int); | |
566 t = ntkns + 1; | |
567 ntkns += pr_gram_levels - 1; | |
568 check_size(map_token_number, ntkns, ntkns); | |
569 tn[0] = pr_gram_base; | |
570 tn[pr_gram_levels] = pr_gram; | |
571 map_token_number[pr_gram].non_terminal_flag = 1; | |
572 for (i = 1; i < pr_gram_levels; i++,t++ ) { | |
573 map_token_number[t].non_terminal_flag = 1; | |
574 tn[i] = t; | |
575 } | |
576 while (pr_gram_levels) { | |
577 switch (fis()) { | |
578 case la_op: | |
579 la_op_forms(tn[pr_gram_levels], tn[pr_gram_levels-1]); | |
580 break; | |
581 case ra_op: | |
582 ra_op_forms(tn[pr_gram_levels], tn[pr_gram_levels-1]); | |
583 break; | |
584 case pr_op: | |
585 pr_op_forms(tn[pr_gram_levels], tn[pr_gram_levels-1]); | |
586 break; | |
587 case su_op: | |
588 su_op_forms(tn[pr_gram_levels], tn[pr_gram_levels-1]); | |
589 break; | |
590 } | |
591 pr_gram_levels--; | |
592 } | |
593 } | |
594 } | |
595 /* | |
596 parameter names | |
597 -> simple name =pl1 | |
598 -> parameter names, mid line white..., comma, simple space, simple name =pl2 | |
599 -> parameter names, comma, simple space, simple name =pl2 | |
600 */ | |
601 parameter name list | |
602 -> =pl4 ; | |
603 -> '\', simple space, parameter names, mid line white..., continuation =pl3; | |
604 -> '\', simple space, parameter names, comment, | |
605 mid line white?..., continuation =pl3; | |
606 | |
607 single parameter | |
608 -> =pl6; | |
609 -> '\', simple space, simple name, mid line white..., continuation =pl5; | |
610 -> '\', simple space, simple name, comment, | |
611 mid line white?..., continuation =pl5; | |
612 | |
613 parameter names | |
614 -> simple name, mid line white..., comma, simple space, simple name | |
615 -> simple name, comma, simple space, simple name | |
616 | |
617 { | |
618 pl1() {ids(cvar_dict); sws(fis());} | |
619 pl2() {ids(cvar_dict); aws(fis());} | |
620 pl3() { | |
621 int right; | |
622 | |
623 ids(cvar_dict); | |
624 right = fis(); | |
625 ids(cvar_dict); | |
626 sis(right); | |
627 } | |
628 pl4() {sis(0); sis(0);} | |
629 pl5() {ids(cvar_dict);} | |
630 pl6() {sis(0);} | |
631 } | |
632 levels | |
633 -> end of line?, level | |
634 -> levels, end of line, level | |
635 | |
636 level | |
637 -> "%bl", simple space, parameter name list, operators =pg_level_la | |
638 -> "%br", simple space, parameter name list, operators =pg_level_ra; | |
639 -> "%up", simple space, single parameter, operators =pg_level_pr; | |
640 -> "%us", simple space, single parameter, operators =pg_level_su | |
641 | |
642 operators | |
643 -> form element = la_op_1(int); | |
644 -> form element, '=', | |
645 simple space, proc spec =la_op_2(int, int); | |
646 -> operators, comma, simple space, form element =la_op_3(int); | |
647 -> operators, comma, simple space, form element, | |
648 '=', simple space, proc spec =la_op_4(int, int); | |
649 { | |
650 pg_level_la() { | |
651 sis(la_op); | |
652 pr_gram_levels++; | |
653 } | |
654 pg_level_ra() { | |
655 sis(ra_op); | |
656 pr_gram_levels++; | |
657 } | |
658 pg_level_pr() { | |
659 sis(pr_op); | |
660 pr_gram_levels++; | |
661 } | |
662 pg_level_su() { | |
663 sis(su_op); | |
664 pr_gram_levels++; | |
665 } | |
666 la_op_1(int tn) { | |
667 sws(tn); aws(0); | |
668 } | |
669 | |
670 la_op_2(int tn,int pn) { | |
671 sws(tn); aws(pn); | |
672 } | |
673 | |
674 la_op_3(int tn) { | |
675 aws(tn); aws(0); | |
676 } | |
677 | |
678 la_op_4(int tn,int pn) { | |
679 aws(tn); aws(pn); | |
680 } | |
681 | |
682 pr_op_forms(int hltn, int lltn) { | |
683 int name; | |
684 token_number_map tm; | |
685 int op, *op_list, i, k, pn,fn; | |
686 int pf; | |
687 int arg; | |
688 | |
689 op_list = build_list(); | |
690 k = fis(); | |
691 arg = fis(); | |
692 pf1(0,lltn,0); | |
693 fn = form2(); | |
694 form_spec_2(fn,0); | |
695 at(bnf_table,hltn,fn); | |
696 map_form_number[fn].prim_tkn = hltn; | |
697 for (i = 0; i< k;) { | |
698 op = op_list[i++]; | |
699 pn = op_list[i++]; | |
700 pf = (pn && map_proc_name[pn].n_params); | |
701 pf1(0,op,0); | |
702 pf2(pf,hltn,arg); | |
703 fn = form2(); | |
704 form_spec_2(fn,pn); | |
705 at(bnf_table,hltn,fn); | |
706 map_form_number[fn].prim_tkn = hltn; | |
707 } | |
708 free(op_list); | |
709 } | |
710 | |
711 ra_op_forms(int hltn, int lltn) { | |
712 int name; | |
713 token_number_map tm; | |
714 int op, *op_list, i, k, pn,fn; | |
715 int pf; | |
716 int right, left; | |
717 | |
718 op_list = build_list(); | |
719 k = fis(); | |
720 right = fis(); | |
721 left = fis(); | |
722 pf1(0,lltn,0); | |
723 fn = form2(); | |
724 form_spec_2(fn,0); | |
725 at(bnf_table,hltn,fn); | |
726 map_form_number[fn].prim_tkn = hltn; | |
727 for (i = 0; i< k;) { | |
728 op = op_list[i++]; | |
729 pn = op_list[i++]; | |
730 pf = (pn && map_proc_name[pn].n_params); | |
731 pf1(pf,lltn,left); | |
732 pf2(0,op,0); | |
733 pf2(pf,hltn,right); | |
734 fn = form2(); | |
735 form_spec_2(fn,pn); | |
736 at(bnf_table,hltn,fn); | |
737 map_form_number[fn].prim_tkn = hltn; | |
738 } | |
739 free(op_list); | |
740 } | |
741 | |
742 su_op_forms(int hltn, int lltn) { | |
743 int name; | |
744 token_number_map tm; | |
745 int op, *op_list, i, k, pn,fn; | |
746 int pf; | |
747 int arg; | |
748 | |
749 op_list = build_list(); | |
750 k = fis(); | |
751 arg = fis(); | |
752 pf1(0,lltn,0); | |
753 fn = form2(); | |
754 form_spec_2(fn,0); | |
755 at(bnf_table,hltn,fn); | |
756 map_form_number[fn].prim_tkn = hltn; | |
757 for (i = 0; i< k;) { | |
758 op = op_list[i++]; | |
759 pn = op_list[i++]; | |
760 pf = (pn && map_proc_name[pn].n_params); | |
761 pf1(pf,hltn,arg); | |
762 pf2(0,op,0); | |
763 fn = form2(); | |
764 form_spec_2(fn,pn); | |
765 at(bnf_table,hltn,fn); | |
766 map_form_number[fn].prim_tkn = hltn; | |
767 } | |
768 free(op_list); | |
769 } | |
770 | |
771 la_op_forms(int hltn, int lltn) { | |
772 int name; | |
773 token_number_map tm; | |
774 int op, *op_list, i, k, pn,fn; | |
775 int pf; | |
776 int left,right,type; | |
777 | |
778 op_list = build_list(); | |
779 k = fis(); | |
780 right = fis(); | |
781 left = fis(); | |
782 pf1(0,lltn,0); | |
783 fn = form2(); | |
784 form_spec_2(fn,0); | |
785 at(bnf_table,hltn,fn); | |
786 map_form_number[fn].prim_tkn = hltn; | |
787 type = map_token_number[lltn].cast; | |
788 if (type == 0) type = default_token_type; | |
789 for (i = 0; i< k;) { | |
790 op = op_list[i++]; | |
791 pn = op_list[i++]; | |
792 pf = (pn && map_proc_name[pn].n_params); | |
793 pf1(pf,hltn,left); | |
794 pf2(0,op,0); | |
795 pf2(pf,lltn,right); | |
796 fn = form2(); | |
797 form_spec_2(fn,pn); | |
798 if (pn && map_proc_name[pn].auto_proc) finish_proc_def(pn,fn,type); | |
799 at(bnf_table,hltn,fn); | |
800 map_form_number[fn].prim_tkn = hltn; | |
801 } | |
802 free(op_list); | |
803 } | |
804 } | |
805 | |
806 statement list | |
807 -> space | |
808 -> statement list, statement | |
809 | |
810 file $ | |
811 -> statement list, unterminated statement, eof | |
812 | |
813 | |
814 complete production | |
815 -> production, end of line | |
816 | |
817 production | |
818 -> head list =pr1(); | |
819 -> head list, "->", blanks, form specs =pr2; | |
820 -> type definition, head list =pr3(int); | |
821 -> type definition, head list, "->", blanks, form specs | |
822 -> complete production, "->", blanks, form specs =pr4(int); | |
823 | |
824 type definition | |
825 -> '(', simple space, cast, ')', simple space =typedef2; | |
826 { | |
827 typedef2() {ids(cast_dict); return fis();} | |
828 pr1() {iws(); return default_token_type;} | |
829 pr2() { return default_token_type;} | |
830 pr3(int type) { | |
831 iws(); | |
832 return type; | |
833 } | |
834 pr4(int type) { concat_list(); return type;} | |
835 | |
836 } | |
837 | |
838 virtual production | |
839 -> string =vp_s; | |
840 -> '{', simple space, vp form specs, '}', blanks =vp_1; | |
841 -> '{', simple space, vp form specs, '}', "...", blanks =vp_2; | |
842 -> '[', simple space, vp form specs, ']', blanks =vp_3; | |
843 -> '[', simple space, vp form specs, ']', "...", blanks =vp_4; | |
844 -> vp form element, '?', blanks =vp_5(int); | |
845 -> vp form element, '?', "...", blanks =vp_6(int); | |
846 -> vp form element, "...", blanks =vp_7(int); | |
847 -> mid line action =vp_8(int); | |
848 | |
849 complete embedded c | |
850 -> embedded c, end of line | |
851 /* | |
852 -> '{', c code, '}', blanks, end of line | |
853 */ | |
854 | |
855 embedded c | |
856 /* -> '{', c code */ | |
857 -> '{', c code, '}', blanks | |
858 | |
859 c code -> c text = copyoff; | |
860 | |
861 c text | |
862 -> = copyon; | |
863 -> c text, c char | |
864 | |
865 { | |
866 c comment text | |
867 -> | |
868 -> c comment text, ~star & ~slash & ~eof | |
869 -> c comment text, slash, ~star & ~eof | |
870 -> c comment text, star, ~slash & ~eof | |
871 -> c comment text, c comment | |
872 | |
873 c comment | |
874 -> slash, star, c comment text, star, slash | |
875 | |
876 c comment | |
877 -> c comment body, slash | |
878 | |
879 c comment body | |
880 -> c comment text, star | |
881 -> c comment body, star | |
882 | |
883 c comment text | |
884 -> slash, star | |
885 -> c comment text, ~star & ~slash & ~eof | |
886 -> c comment text, slash, ~star & ~eof | |
887 -> c comment body, ~star & ~slash & ~eof | |
888 | |
889 c comment text, c comment | |
890 -> c comment text, c comment | |
891 | |
892 | |
893 c literal string | |
894 -> dquote | |
895 -> c literal string, c literal elem | |
896 -> c literal string, squote | |
897 -> c literal string, backslash, anything | |
898 | |
899 c literal char | |
900 -> squote | |
901 -> c literal char, c literal elem | |
902 -> c literal char, dquote | |
903 -> c literal char, backslash, anything | |
904 | |
905 |