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