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