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