comparison tests/agcl/oldagsrc/pgg24a.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 {/*
2 AnaGram Syntax Analyzer.
3 Copyright (c) Jerome T. Holland, 1989, 1990, 1991, 1992
4 All Rights Reserved.
5 */
6 #include HEADERS
7 #include STDLIB
8 #include STDIO
9 #include STRING
10 #include DATA
11 #include TREES
12 #include STK
13 #include CTYPE
14 #include ASSERT
15 #include PGG
16 #include MYALLOC
17 #include UT
18 }
19
20 [
21 auto resynch
22 context type = cint
23 default reductions
24 ~declare pcb
25 diagnose errors
26 // far tables
27 // enum constant name = "pgg_%_token"
28 lines and columns
29 error frame
30 // line numbers
31 ~allow macros
32 nest comments
33 parser stack size = 128
34 pointer input
35 // rule coverage
36 ~test range
37 token names
38 parser name = pgg
39 test file mask = "*.syn"
40
41 distinguish keywords {'.'}
42 // coverage file name = "e:\\agc\\pgg24.nrc"
43 // near functions
44 parser file name = "#.cpp"
45 ]
46
47 any digit = digit + hex letter
48 anything = ~eof
49 backslash = '\\'
50 blank char = ' ' + tab
51 c literal elem = ~(single quote + double quote + eol chars + backslash + eof)
52 digit = '0-9'
53 double quote = '"'
54 eof = 0 + 26
55 eol chars = carriage return + newline
56 hex letter = 'a-f' + 'A-F'
57 letter = 'a-z' + 'A-Z' + '_'
58 newline = '\n'
59 nonoctal digit = any digit - octal digit
60 octal digit = '0-7'
61 carriage return= '\r'
62 simple c char = ~('{' + '}' + single quote + double quote + eof)
63 simple string char = ~eof - (any digit + double quote + backslash + eol chars)
64 single quote = '\''
65 tab = '\t'
66 vertical space = '\f' + '\v'
67
68 arrow
69 -> "->", blank?...
70
71 comma
72 -> ',', space?
73
74 ellipsis
75 -> "...", blank?...
76
77 equals
78 -> '=', space? =n_statements++;
79
80 bang
81 -> '!', space? =n_statements++;
82
83 left brace
84 -> '{', space?
85
86 left bracket
87 -> '[', space?
88
89 left parenthesis
90 -> '(', space?
91
92 minus
93 -> '-', space?
94
95 plus
96 -> '+', space?
97
98 right bracket
99 -> ']', blank?...
100
101 right brace
102 -> '}', blank?...
103
104 right parenthesis
105 -> ')', blank?...
106
107 right quote
108 -> single quote, blank?...
109
110 tilde
111 -> '~', space?
112
113 vertical bar
114 -> '|', space?
115
116 (void) syntax definition $
117 -> blank?..., end of line?, [complete statement..., statement?], eof
118
119 (void) complete statement
120 -> production:t, end of line =production(t);
121 -> simple statement, end of line =n_statements++;
122
123 (void) statement
124 -> production:t =production(t);
125 -> simple statement =n_statements++;
126
127 (int) production
128 -> left hand side:type =iws(),type;
129 -> left hand side, right hand side
130 -> production:type, end of line, right hand side =concat_list(),type;
131 -> production, end of line, additional rule spec...
132
133 (void) right hand side
134 -> arrow, rule specs
135
136 (void) simple statement
137 -> definition
138 -> embedded c
139 -> configuration section
140
141 (int) left hand side
142 -> token name list =n_statements++, 0;
143 -> type definition:d, token name list =n_statements++, head_list_3(d);
144
145 (void) token name list //left hand side of productions
146 -> token name:x =sws(head_list_2(x));
147 -> token name list, comma, token name:x =aws(head_list_2(x));
148
149 (int) token name
150 -> name =0;
151 -> name, '$', blank?... =1;
152
153 (int) type definition
154 -> left parenthesis, data type, ')', space? =ids(cast_dict),fis();
155
156 (void) proper vp rule specs
157 -> vp rule spec:n =sws(n);
158 -> proper vp rule specs, additional vp rule spec
159
160 (void) additional vp rule spec
161 -> vertical bar, vp rule spec:n =aws(n);
162
163 (void) vp rule specs
164 -> reduction procedure:pn =sws((iws(),vp_form3(pn)));
165 -> vp rule specs, additional vp rule spec
166
167 (void) vp rules
168 -> vp rule specs | proper vp rule specs
169
170 (int) vp rule spec
171 -> grammar rule, reduction procedure:s =vp_form3(s);
172
173 (void) rule specs
174 -> reduction procedure:n =sws(form_spec_2(form1(),n));
175 -> rule spec:n =sws(n);
176 -> rule specs, additional rule spec
177
178 (void) additional rule spec
179 -> vertical bar, rule spec:n =aws(n);
180
181 (int) rule spec
182 -> grammar rule, reduction procedure:s =form_spec_2(form2(),s);
183
184 (void) grammar rule
185 -> rule element:e, parameter name:p =iws(),pf2x(e,p);
186 /*
187 -> grammar rule, comma,
188 rule element:e, parameter name:p =pf2x(e,p);
189 */
190
191 -> grammar rule head,
192 rule element:e, parameter name:p =pf2x(e,p);
193
194 grammar rule head
195 -> grammar rule, comma
196
197 (int) reduction procedure
198 -> =0;
199 -> equals, embedded c =proc_spec_4(0);
200 -> equals, c expression, ';', blank?... =proc_spec_4(1);
201
202 (void) data type
203 -> type name
204 -> type name, template field
205 -> type name, template field?, abstract declarator =concat_string();
206
207 (void) type name
208 -> name
209 -> "::", !sss("::");, blank?..., name =concat_string();
210 -> type name, "::", !ass("::");, blank?..., name =concat_string();
211
212 (void) abstract declarator
213 -> indirect data type
214 -> direct abstract declarator
215 -> indirect data type, direct abstract declarator =concat_string();
216
217 (void) template field
218 // -> {'<', blank?... = acs('<');}, data type, '>', blank?... =acs('>'), concat_string();
219 -> template field head, data type, '>', blank?... =acs('>'), concat_string();
220
221 template field head
222 -> '<', blank?... = acs('<');
223 -> template field head, data type, ',', blank?... =acs(','), concat_string();
224
225
226
227 (void) direct abstract declarator
228 -> {left parenthesis =scs('(');}, abstract declarator,
229 right parenthesis =concat_string(), acs(')');
230
231 (void) star
232 -> '*', blank?... =sss(" *");
233
234 (void) pointer
235 -> star
236 -> star, name =concat_string();
237
238 (void) indirect data type
239 -> pointer
240 -> indirect data type, pointer =concat_string();
241
242 (void) name string
243 -> letter:c =scs(c);
244 -> name string, letter + digit :c =acs(c);
245 -> name string, blank..., letter + digit :c =acs(' '), acs(c);
246
247 (void) enum fix
248 -> "enum", blank..., letter + digit : c =sss("enum "), acs(c);
249 -> enum fix, letter + digit:c =acs(c);
250 -> enum fix, blank..., letter + digit:c =acs(' '), acs(c);
251
252 (void) name
253 -> name string, blank?...
254
255 (void) blank
256 -> blank char
257 -> c comment
258
259 (void) space
260 -> blank...
261 -> blank..., continuation
262 -> continuation
263
264 (void) continuation
265 -> comment, next line
266 -> next line
267
268 (void) next line
269 -> carriage return?, newline
270 -> carriage return?, newline, blank...
271
272 (void) white
273 -> blank
274 -> carriage return?, newline
275 -> comment, carriage return?, newline
276
277 (void) end of line
278 -> comment, carriage return?, newline
279 -> carriage return?, newline
280 -> end of line, white
281 -> end of line, vertical space //form feed
282
283 (void) comment
284 -> "//", ~eol chars & ~eof?...
285
286 (int) character
287 -> signed number
288 -> '^', 33..126:x, blank?... =x & 0x1f;
289
290 (int) quoted character
291 -> single quote, char const:c, right quote =(character_seen=1),c;
292
293 /*
294 (CharSetExpression *) character
295 -> signed number:n =new IndividualCode(n);
296 -> '^', 33..126:x, blank?... =new IndividualCode(x & 0x1f);
297 -> single quote, char const:c, right quote =(character_seen=1),new IndividualChar(c);
298 */
299 (int) signed number
300 -> sign:s, simple number:n, blank?... =s*n;
301
302 (int) sign
303 -> plus? =1;
304 -> minus =-1;
305
306 (int) simple number
307 -> decimal number
308 -> '0', octal number:n =n;
309 -> {"0x" | "0X"}, hex number:n =n;
310
311 (int) decimal number
312 -> '1-9':d =d - '0';
313 -> decimal number:n, '0-9':d =10*n + d - '0';
314
315 (int) octal number
316 -> =0;
317 -> octal number:n, '0-7':d =8*n + d - '0';
318
319 (int) hex number
320 -> hex digit:d =d;
321 -> hex number:n, hex digit:d =16*n + d;
322
323 (int) hex digit
324 -> '0-9':d =d-'0';
325 -> 'a-f' + 'A-F':d =(d&7)+9;
326
327 (int) rule element
328 -> token
329 -> mid rule action:p =vp_8a(p);
330
331 (int) token
332 -> union:n =form_element_1(n);
333 -> virtual production
334
335 /*
336 (node) union
337 -> intersection
338 -> union:u, plus, intersection:i =make_or_node(u,i);
339 -> union:u, minus, intersection:i =make_minus_node(u,i);
340
341 (node) intersection
342 -> negation
343 -> intersection:i, '&', space?, negation:n =make_and_node(i,n);
344
345 (node) negation
346 -> simple set
347 -> tilde, negation:n =make_tilde_node(n);
348 */
349 (CharSetExpression *) union
350 -> intersection
351 -> union:u, plus, intersection:i =new CharSetUnion(u,i);
352 -> union:u, minus, intersection:i =new CharSetDifference(u,i);
353
354 (CharSetExpression *) intersection
355 -> negation
356 -> intersection:i, '&', space?, negation:n =new CharSetIntersection(i,n);
357
358 (CharSetExpression *) negation
359 -> simple set
360 -> tilde, negation:n =new CharSetComplement(n);
361
362 (int) char const
363 -> anything -(single quote + backslash + eol chars):c =
364 case_sensitive ? (c) : toupper(c);
365 -> escape sequence
366 -> octal escape
367 -> three octal
368 -> hex escape
369
370 /*
371 (node) simple set
372 -> character range =ss3();
373 -> character:n =ss1(n); //=ss4(n);
374 -> name =ss2();
375 -> left parenthesis, union:x,
376 right parenthesis =x;
377
378 (void) character range
379 -> single quote, char const:l, '-', char const:r, right quote =
380 (character_seen=1),range(l,r);
381 -> character:l, "..", space?, character:r =range(l,r);
382 */
383
384 (CharSetExpression *) simple set
385 -> character range
386 -> character:c =new IndividualCode(c);
387 -> quoted character:c =new IndividualChar(c);
388 -> name =ss2();
389 -> left parenthesis, union:x,
390 right parenthesis =x;
391
392 (CharSetExpression *) character range
393 -> single quote, char const:l, '-',
394 char const:r, right quote =(character_seen=1),new CharRange(l,r);
395 -> character:l, "..", space?, character:r =new CodeRange(l,r);
396
397 (void) definition
398 -> name, equals, union:n =definition_1(n);
399 -> name, equals, virtual production:p =definition_2(p);
400 -> name, equals, mid rule action:p =definition_2(vp_8a(p));
401
402 (void) enum definition
403 -> name =definition_3(enum_base++);
404 -> name, equals, character:n =definition_3(enum_base = n), enum_base++;
405 -> name, equals, quoted character:n =definition_3(enum_base = n), enum_base++;
406
407 (void) enum statement
408 -> "enum", space, left brace, enum definition
409 -> enum statement, comma, enum definition
410
411 (void) keyword string
412 -> keyword string head, string, double quote, blank?...
413
414 (void) string
415 -> string A | string B | string C
416
417 (void) keyword string head
418 -> double quote =ics();
419
420 (int) string char
421 -> simple string char
422 -> escape sequence
423 -> three octal:n =null_warning(n);
424
425 (int) escape sequence
426 -> "\\a" ='\a';
427 -> "\\b" ='\b';
428 -> "\\f" ='\f';
429 -> "\\n" ='\n';
430 -> "\\r" ='\r';
431 -> "\\t" ='\t';
432 -> "\\v" ='\v';
433 -> "\\\\" ='\\';
434 -> "\\?" = '\?';
435 -> "\\'" ='\'';
436 -> "\\\"" ='"';
437
438 {
439 int null_warning(int n) {
440 extern void warning_here(const char *,...);
441 if (n == 0) warning_here("Null character in keyword string");
442 return n;
443 }
444 }
445
446 (int) one octal
447 -> backslash, '0-7':n =n&7;
448
449 (int) two octal
450 -> one octal:n, '0-7':d =n*8 + (d&7);
451
452 (int) three octal
453 -> two octal:n, '0-7':d =n*8 + (d&7);
454
455 (int) octal escape
456 -> one octal | two octal
457
458 (int) hex escape
459 -> "\\x", hex number:x =x;
460
461 (void) string A
462 -> string char:c =acs(c);
463 -> any digit:c =acs(c);
464 -> string, string char:c =acs(c);
465 -> string A, any digit:c =acs(c);
466 -> string B, nonoctal digit:c =acs(c);
467
468 (void) string B
469 -> octal escape:c =acs(null_warning(c));
470 -> string, octal escape:c =acs(null_warning(c));
471
472 (void) string C
473 -> hex escape:c =acs(null_warning(c));
474 -> string, hex escape:c =acs(null_warning(c));
475
476 (int) parameter name
477 -> =0;
478 -> ':', space?, c name =ids(cvar_dict),fis();
479
480 (void) simple name
481 -> letter:c =scs(c);
482 -> simple name, letter + digit:c =acs(c);
483
484 (void) c name
485 -> simple name, blank?...
486
487 (void) configuration section
488 // -> '[', blank?..., [global parameter | end of line]/..., right bracket
489 -> '[', configuration parameters, right bracket
490
491 (void) configuration parameters
492 -> blank?..., end of line?, [configuration parameter list, end of line?]
493
494 (void) configuration parameter list
495 -> configuration parameter
496 -> configuration parameter list, end of line, configuration parameter
497
498
499 (void) configuration parameter
500 -> name =gp4(1);
501 -> tilde, name =gp4(0);
502 -> name, equals, data type =gp2();
503 -> name, equals, keyword string =gp3();
504 -> enum fix, blank?..., equals, keyword string =gp3();
505 -> name, equals, signed number:n =gp5(n);
506 -> attribute statement
507 /*
508 -> "distinguish", blank..., "lexemes", blank?... =
509 sss("distinguish_lexemes"), gp4(1);
510 */
511 -> keyword kluge, name =concat_string(), gp4(1);
512
513 keyword kluge
514 -> "distinguish", blank... =sss("distinguish_");
515
516 (void) attribute statement
517 -> "left", token list =set_prec(1,0);
518 -> "right", token list =set_prec(0,1);
519 -> "nonassoc", token list =set_prec(0,0);
520 -> "sticky", token list =set_sticky();
521 -> "subgrammar", token list =set_subgrammar();
522 -> "hidden", token list =set_hidden();
523 -> new reserve statement, list end //=new_reserve();
524 -> enum statement, list end
525 -> "disregard", blank..., token:t =disregard(t);
526 -> "lexeme", token list =set_lexeme();
527 -> "reserve", blank..., "keywords", token list =set_reserved_words();
528 -> "rename", blank..., "macro",blank...,
529 macro name:oldName, blank..., macro name:newName =at(rename_macro_list,oldName,newName);
530
531 (int) macro name
532 -> letter =(PCB).pointer-input_base-1;
533 -> macro name, letter + digit
534
535 list end
536 -> [comma | continuation], right brace
537
538 (void) new reserve statement
539 -> "distinguish", blank..., "keywords", blank..., left brace,
540 union:n =distinguishSets.push(identify_node(n));
541 // union:n =init_reserve(identify_node(n));
542 -> new reserve statement, comma, union:n =distinguishSets.push(identify_node(n));
543 // -> new reserve statement, comma, union:n =aws(identify_node(n));
544
545 (void) token list
546 -> blank..., left brace, tokens, list end
547
548 (void) tokens
549 -> token:t =sws(t);
550 -> tokens, comma, token:t =aws(t);
551
552 (int) virtual production
553 -> keyword string =vp_s();
554 -> keyword string, '?', blank?... =vp_5(vp_s());
555 -> left brace, vp rules, right brace =vp_1();
556 -> left brace, vp rules, "}...", blank?... =vp_2();
557 -> left bracket, proper vp rule specs, right bracket =vp_3();
558 -> left bracket, proper vp rule specs, "]...", blank?... =vp_4();
559 -> union:n, '?', blank?... =vp_5(form_element_1(n));
560 -> union:n, "?...", blank?... =vp_6(form_element_1(n));
561 -> union:n, ellipsis =vp_7(form_element_1(n));
562 -> left brace, proper vp rule specs, "}/...", blank?... =vp_9();
563 -> left bracket, proper vp rule specs, "]/...", blank?... =vp_10();
564
565 (int) mid rule action
566 -> bang, embedded c =mid_line(proc_spec_4(0));
567 -> bang, c expression, ';', blank?... =mid_line(proc_spec_4(1));
568
569 (void) embedded c
570 -> embedded c head, c code, right brace
571
572 (void) embedded c head
573 -> '{', [carriage return?, newline]... =copyon();
574
575 (void) c code
576 -> =copyoff();
577 -> c code first, c text =copyoff();
578
579 (void) c code first
580 -> simple c char - eol chars
581 -> c comment
582 -> comment, carriage return?, newline
583 -> c character constant, single quote
584 -> c string constant, double quote
585
586 (void) c text
587 ->
588 -> c text, c char
589
590 (void) c char //c char represents the content of embedded c
591 -> simple c char
592 -> '{', c text, '}'
593 -> c comment
594 -> comment, carriage return?, newline
595 -> c character constant, single quote
596 -> c string constant, double quote
597
598 (void) c expression head
599 -> =copyon();
600
601 (void) c expression
602 -> c expression head, c chars =copyoff();
603
604 (void) c chars
605 -> c expression char
606 -> c chars, c expression char
607 -> c chars, blank
608
609 (void) c expression char //c char represents the content of embedded C
610 -> simple c char - ';' - eol chars - blank char
611 -> "\\\n"
612 -> c character constant, single quote
613 -> c string constant, double quote
614
615 (void) c comment
616 -> c comment head, "*/"
617
618 (void) c comment head
619 -> "/*"
620 -> c comment head, ~eof
621
622 (void) c comment, c comment head
623 -> c comment head, c comment =
624 {if (nest_comments) PCB.reduction_token = pgg_c_comment_head_token;}
625
626 (void) c string constant
627 -> double quote, [c literal elem | single quote | backslash, anything]...
628
629 (void) c character constant
630 -> single quote, [c literal elem | double quote | backslash, anything]...
631
632 [
633 hidden {
634 arrow, comma, ellipsis, equals, left brace,
635 left bracket, left parenthesis, minus, plus, right bracket,
636 list end,
637 right brace, right parenthesis, right quote, star, tilde,
638 vertical bar, simple statement, token name,
639 rule spec, pointer, indirect data type, name string,
640 blank, space, next line, white, end of line, sign, simple number,
641 simple set, one octal, two octal, three octal,
642 string A, string B, string C,
643 simple name, c text, c char, c chars, c expression char,
644 c expression head,
645 c comment head,
646 c code, c name,
647 bang,
648 complete statement,
649 rule specs, vp rule specs, additional rule spec,
650 data type, template field, abstract declarator,
651 direct abstract declarator, pointer,
652 name string, proper vp rule specs, additional vp rule spec,
653 new reserve statement, anything, union, intersection, negation,
654 grammar rule head, enum fix
655 }
656 ]
657
658 {
659 pgg_pcb_type pgcb;
660 #define PCB pgcb
661
662 #define PARSER_STACK_OVERFLOW parse_stack_overflow()
663 #define SYNTAX_ERROR log_syntax_error()
664 #define GET_CONTEXT CONTEXT.y = PCB.line, CONTEXT.x = PCB.column;
665
666 #define REDUCTION_TOKEN_ERROR reduction_token_error()
667
668 int save_case_sensitive;
669
670 void reduction_token_error(void) {
671 assert(0);
672 }
673
674 extern tsd *rename_macro_list;
675
676 extern int parse_abort_flag;
677 void log_error_location(int, int);
678 void log_error(void);
679 void show_error(void);
680
681 void parse_stack_overflow(void) {
682 int eline = PCB.line, ecol = PCB.column;
683 reset_stk();
684 log_error_location(ecol,eline);
685 ass("Nesting too deep");
686 log_error();
687 sss("Syntax Analysis aborted");
688 show_error();
689 parse_abort_flag = 1;
690 PCB.exit_flag = AG_SEMANTIC_ERROR_CODE;
691 }
692
693 extern string_dict *cast_dict;
694 extern int character_seen;
695 extern int enum_base;
696 extern unsigned char *input_base;
697 extern int nest_comments;
698 extern int precedence_level;
699 extern int syntax_error_flag;
700 extern int case_sensitive;
701 extern int n_statements;
702
703 void log_error_location(int,int);
704 void log_error_here(void);
705 void log_error(void);
706
707 //node make_or_node(node,node);
708 //node make_and_node(node,node);
709 //node make_minus_node(node,node);
710 //node make_tilde_node(node);
711 //node ss1(int);
712 //node ss2(void);
713 CharSetExpression *ss2(void);
714 //node ss3(void);
715
716 void acs(int);
717 void aws(int);
718 void atkn(unsigned);
719 void copyoff(void);
720 void copyon(void);
721 //void definition_1(node);
722 void definition_1(CharSetExpression *);
723 void definition_2(int);
724 void definition_3(int);
725 //int form_element_1(node);
726 int form_element_1(CharSetExpression *);
727 int form_spec_2(int, int);
728 int form1(void);
729 int form2(void);
730 void gp2(void);
731 void gp3(void);
732 void gp4(int);
733 void gp5(int);
734 int head_list_1(int);
735 int head_list_2(int);
736 static int head_list_3(int);
737 void ics(void);
738 //int identify_node(node);
739 int identify_node(CharSetExpression *);
740 //void init_reserve(int);
741 void iws(void);
742 int mid_line(int);
743 int new_cast_spec_1(void);
744 int new_cast_spec_2(void);
745 //void new_reserve(void);
746 int null_warning(int);
747 /* void pf2(int, int, int); */
748 void pf2x(int, int);
749 int pr3(int);
750 int pr4(int);
751 int proc_spec_4(int);
752 int proc_spec_5(void);
753 void production(int);
754 void range(int, int);
755 void scs(int);
756 static void set_prec(int,int);
757 /*
758 void suppress(void);
759 void suppress_all(void);
760 void suppress_except(void);
761 void suppress_initial(void);
762 */
763 void sws(int);
764 void tp4(int);
765 int vp_form3(int);
766 int vp_s(void);
767 int vp_1(void);
768 int vp_2(void);
769 int vp_3(void);
770 int vp_4(void);
771 int vp_5(int);
772 int vp_6(int);
773 int vp_7(int);
774 int vp_8(int);
775 int vp_8a(int);
776 int vp_9(void);
777 int vp_10(void);
778
779 /*
780 static int reserve(int pt) {
781 int key = map_token_number[vp_s()].key;
782 map_key_word[key].reserve = pt;
783 return pt;
784 }
785 */
786
787 /*
788 static void anomalous(void) {
789 map_token_number[vp_s()].anomalous = 1;
790 }
791 */
792
793 int *disregard_list = NULL;
794 int n_disregard_list = 0;
795
796 static void disregard(int tn) {
797 iws();
798 if (n_disregard_list) {
799 int *p = disregard_list;
800 while (n_disregard_list--) aws(*p++);
801 free(disregard_list);
802 }
803 xws(tn);
804 disregard_list = build_list();
805 n_disregard_list = fis();
806 }
807
808 extern tsd *syntax_errors;
809
810 static void log_syntax_error(void) {
811 int eline = PCB.line, ecol = PCB.column;
812 int flag = PCB.error_frame_token == pgg_c_comment_token ||
813 PCB.error_frame_token == pgg_embedded_c_token;
814
815 reset_stk();
816 if (flag && PCB.token_number == pgg_eof_token) {
817 eline = ERROR_CONTEXT.y;
818 ecol = ERROR_CONTEXT.x;
819 }
820 log_error_location(ecol,eline);
821 apprintf("%s in %s",
822 PCB.error_message,pgg_token_names[PCB.error_frame_token]);
823 log_error();
824 syntax_error_flag++;
825 if (syntax_errors->nt < 50) return;
826 sss("Too many syntax errors, parse aborted");
827 log_error();
828 PCB.exit_flag = AG_SYNTAX_ERROR_CODE;
829 }
830
831 static int head_list_3(int type) {
832 int i, n = tis();
833 for (i = 0; i < n; i ++) {
834 int tn = list_base[i];
835 token_number_map *tp = &map_token_number[tn];
836 int ptt = tp->value_type;
837 if (ptt && ptt != type) {
838 log_error_here();
839 apprintf("Type Redefinition of T%03d: ", tn);
840 atkn(tn);
841 log_error();
842 }
843 tp->value_type = type;
844 if (ptt == 0 && tp->rp_arg && type == void_token_type) {
845 log_error_here();
846 apprintf("Void token, %s, used as parameter",
847 dict_str(tkn_dict,tp->token_name));
848 log_error();
849 }
850 }
851 return type;
852 }
853
854 static void set_prec(int left, int right){
855 int n = tis();
856 precedence_level++;
857 while (n--) {
858 int k = list_base[n];
859 token_number_map *tp = &map_token_number[k];
860 tp->left_associative = left;
861 tp->right_associative = right;
862 tp->precedence_level = precedence_level;
863 }
864 rws();
865 }
866
867 static void set_sticky(void){
868 int n = tis();
869 while (n--) {
870 int k = list_base[n];
871 token_number_map *tp = &map_token_number[k];
872 tp->sticky = 1;
873 }
874 rws();
875 }
876
877 static void set_subgrammar(void){
878 int n = tis();
879 while (n--) {
880 int k = list_base[n];
881 token_number_map *tp = &map_token_number[k];
882 tp->subgrammar = 1;
883 }
884 rws();
885 }
886
887 void set_hidden(void) {
888 int *lb = list_base;
889 int n = tis();
890 while (n--) map_token_number[*lb++].fine_structure = 1;
891 rws();
892 }
893
894 void set_lexeme(void) {
895 int n = tis();
896 while (n--) {
897 token_number_map *tp = &map_token_number[list_base[n]];
898 /* tp->lexeme = tp->subgrammar = 1; */
899 tp->lexeme = 1;
900 }
901 rws();
902 }
903
904 void set_reserved_words(void) {
905 int n = tis();
906 while (n--) {
907 token_number_map *tp = &map_token_number[list_base[n]];
908 tp->reserved_word = 1;
909 }
910 rws();
911 }
912
913 void parse(void) {
914 pgcb.pointer = input_base;
915 pgg();
916 }
917 }
918