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