Fix some cleanall issues
[mirror_edk2.git] / Tools / Source / TianoTools / Pccts / dlg / dlg_p.g
CommitLineData
878ddf1f 1/* This is the parser for the dlg\r
2 * This is a part of the Purdue Compiler Construction Tool Set\r
3 *\r
4 * SOFTWARE RIGHTS\r
5 *\r
6 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
7 * Set (PCCTS) -- PCCTS is in the public domain. An individual or\r
8 * company may do whatever they wish with source code distributed with\r
9 * PCCTS or the code generated by PCCTS, including the incorporation of\r
10 * PCCTS, or its output, into commerical software.\r
11 *\r
12 * We encourage users to develop software with PCCTS. However, we do ask\r
13 * that credit is given to us for developing PCCTS. By "credit",\r
14 * we mean that if you incorporate our source code into one of your\r
15 * programs (commercial product, research project, or otherwise) that you\r
16 * acknowledge this fact somewhere in the documentation, research report,\r
17 * etc... If you like PCCTS and have developed a nice tool with the\r
18 * output, please mention that you developed it using PCCTS. In\r
19 * addition, we ask that this header remain intact in our source code.\r
20 * As long as these guidelines are kept, we expect to continue enhancing\r
21 * this system and expect to make other tools available as they are\r
22 * completed.\r
23 *\r
24 * DLG 1.33\r
25 * Will Cohen\r
26 * With mods by Terence Parr; AHPCRC, University of Minnesota\r
27 * 1989-1995\r
28 */\r
29\r
30#header <<\r
31#include <ctype.h>\r
32#include "dlg.h"\r
33>>\r
34\r
35<<\r
36\r
37/* MR20 G. Hobbelt \r
38 Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled\r
39*/\r
40\r
41#ifdef __TURBOC__\r
42#pragma warn -aus /* unused assignment of 'xxx' */\r
43#endif\r
44\r
45int action_no = 0; /* keep track of actions outputed */\r
46int nfa_allocated = 0; /* keeps track of number of nfa nodes */\r
47nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */\r
48nfa_node nfa_model_node; /* model to initialize new nodes */\r
49set used_chars; /* used to label trans. arcs */\r
50set used_classes; /* classes or chars used to label trans. arcs */\r
51set normal_chars; /* mask to get rid elements that aren't used\r
52 in set */\r
53int flag_paren = FALSE;\r
54int flag_brace = FALSE;\r
55int mode_counter = 0; /* keep track of number of %%names */\r
56\r
57>>\r
58\r
59#lexaction <<\r
60int func_action; /* should actions be turned into functions?*/\r
61int lex_mode_counter = 0; /* keeps track of the number of %%names */\r
62/* MR1 */\r
63/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */\r
64/* MR1 via <<%%lexmember...>> */\r
65/* MR1 */\r
66int lexMember = 0; /* <<%%lexmemeber ...>> MR1 */\r
67int lexAction = 0; /* <<%%lexaction ...>> MR1 */\r
68int parserClass = 0; /* <<%%parserclass ...>> MR1 */\r
69int lexPrefix = 0; /* <<%%lexprefix ...>> MR1 */\r
70char theClassName[100]; /* MR11 */\r
71char *pClassName=theClassName; /* MR11 */\r
72int firstLexMember=1; /* MR1 */\r
73\r
74#ifdef __USE_PROTOS\r
75void xxputc(int c) { /* MR1 */\r
76#else\r
77void xxputc(c) /* MR1 */\r
78 int c; /* MR1 */\r
79{ /* MR1 */\r
80#endif\r
81 if (parserClass) { /* MR1 */\r
82 *pClassName++=c; /* MR1 */\r
83 *pClassName=0; /* MR1 */\r
84 } else if (lexMember || lexPrefix) { /* MR1 */\r
85 if (class_stream != NULL) fputc(c,class_stream); /* MR1 */\r
86 } else { /* MR1 */\r
87 fputc(c,OUT); /* MR1 */\r
88 }; /* MR1 */\r
89} /* MR1 */\r
90\r
91#ifdef __USE_PROTOS\r
92void xxprintf(char *format,char *string) { /* MR1 */\r
93#else\r
94void xxprintf(format,string) /* MR1 */\r
95 char *format; /* MR1 */\r
96 char *string; /* MR1 */\r
97{ /* MR1 */\r
98#endif\r
99 if (lexMember || lexPrefix || parserClass) { /* MR1 */\r
100 if (class_stream != NULL) /* MR1 */\r
101 fprintf(class_stream,format,string); /* MR1 */\r
102 } else { /* MR1 */\r
103 fprintf(OUT,format,string); /* MR1 */\r
104 }; /* MR1 */\r
105} /* MR1 */\r
106>>\r
107\r
108#token "[\r\t\ ]+" << zzskip(); >> /* Ignore white */\r
109#token "\n" << zzline++; zzskip(); DAWDLE; >> /* Track Line # */\r
110#token L_EOF "\@"\r
111#token PER_PER "\%\%"\r
112#token NAME_PER_PER "\%\%[a-zA-Z_][a-zA-Z0-9_]*"\r
113 << p_mode_def(&zzlextext[2],lex_mode_counter++); >>\r
114\r
115#token LEXMEMBER "\<\<\%\%lexmember" /* MR1 */\r
116 <<lexMember=1; /* MR1 */\r
117 if (firstLexMember != 0) { /* MR1 */\r
118 firstLexMember=0; /* MR1 */\r
119 p_class_def1(); /* MR1 */\r
120 }; /* MR1 */\r
121 zzmode(ACT); /* MR1 */\r
122 >> /* MR1 */\r
123#token LEXACTION "\<\<\%\%lexaction" /* MR1 */\r
124 <<lexAction=1;zzmode(ACT);>> /* MR1 */\r
125#token PARSERCLASS "\<\<\%\%parserclass" /* MR1 */\r
126 <<parserClass=1; /* MR1 */\r
127 zzmode(ACT); /* MR1 */\r
128 >> /* MR1 */\r
129#token LEXPREFIX "\<\<\%\%lexprefix" /* MR1 */\r
130 <<lexPrefix=1;zzmode(ACT);>> /* MR1 */\r
131\r
132#token ACTION "\<\<"\r
133 << if (func_action)\r
134 fprintf(OUT,"\n%s %sact%d()\n{ ",\r
135 gen_cpp?"ANTLRTokenType":"static void",\r
136 gen_cpp?ClassName("::"):"", ++action_no);\r
137 zzmode(ACT); zzskip();\r
138 >>\r
139#token GREAT_GREAT "\>\>"\r
140#token L_BRACE "\{"\r
141#token R_BRACE "\}"\r
142#token L_PAR "\("\r
143#token R_PAR "\)"\r
144#token L_BRACK "\["\r
145#token R_BRACK "\]"\r
146#token ZERO_MORE "\*"\r
147#token ONE_MORE "\+"\r
148#token OR "\|"\r
149#token RANGE "\-"\r
150#token NOT "\~"\r
151#token OCTAL_VALUE "\\0[0-7]*" \r
152 << {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}>>\r
153#token HEX_VALUE "\\0[Xx][0-9a-fA-F]+"\r
154 << {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}>>\r
155#token DEC_VALUE "\\[1-9][0-9]*"\r
156 << {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}>>\r
157#token TAB "\\t" << zzlextext[0] = '\t';>>\r
158#token NL "\\n" << zzlextext[0] = '\n';>>\r
159#token CR "\\r" << zzlextext[0] = '\r';>>\r
160#token BS "\\b" << zzlextext[0] = '\b';>>\r
161\r
162/* MR1 */\r
163/* MR1 10-Apr-97 MR1 Allow #token regular expressions to cross lines */\r
164/* MR1 */\r
165#token CONTINUATION "\\ \n" << zzline++; zzskip();>> /* MR1 */\r
166\r
167/* NOTE: this takes ANYTHING after the \ */\r
168#token LIT "\\~[tnrb]" << zzlextext[0] = zzlextext[1];>>\r
169\r
170/* NOTE: this takes ANYTHING that doesn't match the other tokens */\r
171#token REGCHAR "~[\\]"\r
172\r
173\r
174grammar : << p_head(); p_class_hdr(); func_action = FALSE;>>\r
175 ( {LEXACTION | LEXMEMBER | LEXPREFIX | PARSERCLASS } ACTION)* /* MR1 */\r
176 <<if ( gen_cpp ) p_includes();>>\r
177 start_states\r
178 << func_action = FALSE; p_tables(); p_tail(); >>\r
179 (ACTION)* "@"\r
180 << if (firstLexMember != 0) p_class_def1(); >> /* MR1 */\r
181 ;\r
182\r
183start_states : ( PER_PER do_conversion\r
184 | NAME_PER_PER do_conversion (NAME_PER_PER do_conversion)*)\r
185 PER_PER\r
186 ;\r
187\r
188do_conversion : <<new_automaton_mode(); func_action = TRUE;>>\r
189 rule_list\r
190 <<\r
191 dfa_class_nop[mode_counter] =\r
192 relabel($1.l,comp_level);\r
193 if (comp_level)\r
194 p_shift_table(mode_counter);\r
195 dfa_basep[mode_counter] = dfa_allocated+1;\r
196 make_dfa_model_node(dfa_class_nop[mode_counter]);\r
197 nfa_to_dfa($1.l);\r
198 ++mode_counter;\r
199 func_action = FALSE;\r
200#ifdef HASH_STAT\r
201 fprint_hash_stats(stderr);\r
202#endif\r
203 >>\r
204 ;\r
205\r
206rule_list : rule <<$$.l=$1.l; $$.r=$1.r;>>\r
207 (rule\r
208 <<{nfa_node *t1;\r
209 t1 = new_nfa_node();\r
210 (t1)->trans[0]=$$.l;\r
211 (t1)->trans[1]=$1.l;\r
212 /* all accept nodes "dead ends" */\r
213 $$.l=t1; $$.r=NULL;\r
214 }\r
215 >>\r
216 )*\r
217 | /* empty */\r
218 <<$$.l = new_nfa_node(); $$.r = NULL;\r
219 warning("no regular expressions", zzline);\r
220 >>\r
221 ;\r
222\r
223rule : reg_expr ACTION\r
224/* MR23 */ << if ($1.r != NULL) {\r
225 $$.l=$1.l; $$.r=$1.r; ($1.r)->accept=action_no;\r
226 }\r
227 >>\r
228 | ACTION\r
229 <<$$.l = NULL; $$.r = NULL;\r
230 error("no expression for action ", zzline);\r
231 >>\r
232 ;\r
233\r
234reg_expr : and_expr <<$$.l=$1.l; $$.r=$1.r;>>\r
235 (OR and_expr\r
236 <<{nfa_node *t1, *t2;\r
237 t1 = new_nfa_node(); t2 = new_nfa_node();\r
238 (t1)->trans[0]=$$.l;\r
239 (t1)->trans[1]=$2.l;\r
240/* MR23 */ if ($$.r != NULL) ($$.r)->trans[1]=t2;\r
241 if ($2.r) {\r
242 ($2.r)->trans[1]=t2; /* MR20 */\r
243 }\r
244 $$.l=t1; $$.r=t2;\r
245 }\r
246 >>\r
247 )*\r
248 ;\r
249\r
250and_expr : repeat_expr\r
251 <<\r
252 $$.l=$1.l; $$.r=$1.r;\r
253 >>\r
254 (repeat_expr \r
255/* MR23 */ << if ($$.r != NULL) {\r
256 ($$.r)->trans[1]=$1.l;\r
257 $$.r=$1.r;\r
258 }\r
259 >>\r
260 )*\r
261 ;\r
262\r
263repeat_expr : expr <<$$.l=$1.l; $$.r=$1.r;>>\r
264 { ZERO_MORE\r
265 <<{ nfa_node *t1,*t2;\r
266/* MR23 */ if ($$.r != NULL) ($$.r)->trans[0] = $$.l;\r
267 t1 = new_nfa_node(); t2 = new_nfa_node();\r
268 t1->trans[0]=$$.l;\r
269 t1->trans[1]=t2;\r
270/* MR23 */ if ($$.r != NULL) ($$.r)->trans[1]=t2;\r
271 $$.l=t1;$$.r=t2;\r
272 }\r
273 >>\r
274 | ONE_MORE\r
275/* MR23 */ <<if ($$.r != NULL) ($$.r)->trans[0] = $$.l;>>\r
276 }\r
277 | ZERO_MORE\r
278 << error("no expression for *", zzline);>>\r
279 | ONE_MORE\r
280 << error("no expression for +", zzline);>>\r
281 ;\r
282\r
283expr : << $$.l = new_nfa_node();\r
284 $$.r = new_nfa_node();\r
285 >>\r
286 L_BRACK atom_list R_BRACK\r
287 <<\r
288/* MR23 */ if ($$.l != NULL) {\r
289 ($$.l)->trans[0] = $$.r;\r
290 ($$.l)->label = set_dup($2.label);\r
291 set_orin(&used_chars,($$.l)->label);\r
292 }\r
293 >>\r
294 | NOT L_BRACK atom_list R_BRACK\r
295 <<\r
296/* MR23 */ if ($$.l != NULL) {\r
297 ($$.l)->trans[0] = $$.r;\r
298 ($$.l)->label = set_dif(normal_chars,$3.label);\r
299 set_orin(&used_chars,($$.l)->label);\r
300 }\r
301 >>\r
302 | L_PAR reg_expr R_PAR\r
303 <<\r
304/* MR23 */ if ($$.l != NULL) { \r
305 ($$.l)->trans[0] = $2.l;\r
306 if ($2.r) {\r
307 ($2.r)->trans[1] = $$.r; /* MR20 */\r
308 }\r
309 }\r
310 >>\r
311 | L_BRACE reg_expr R_BRACE\r
312 <<\r
313/* MR23 */ if ($$.l != NULL) {\r
314 ($$.l)->trans[0] = $2.l;\r
315 ($$.l)->trans[1] = $$.r;\r
316 if ($2.r) {\r
317 ($2.r)->trans[1] = $$.r; /* MR20 */\r
318 }\r
319 }\r
320 >>\r
321 | atom\r
322 <<\r
323/* MR23 */ if ($$.l != NULL) {\r
324 ($$.l)->trans[0] = $$.r;\r
325 ($$.l)->label = set_dup($1.label);\r
326 set_orin(&used_chars,($$.l)->label);\r
327 }\r
328 >>\r
329 ;\r
330\r
331atom_list : << set_free($$.label); >>\r
332 (near_atom <<set_orin(&($$.label),$1.label);>>)*\r
333 ;\r
334\r
335near_atom : << register int i;\r
336 register int i_prime;\r
337 >>\r
338 anychar\r
339 <<$$.letter=$1.letter; $$.label=set_of($1.letter);\r
340 i_prime = $1.letter + MIN_CHAR;\r
341 if (case_insensitive && islower(i_prime))\r
342 set_orel(toupper(i_prime)-MIN_CHAR,\r
343 &($$.label));\r
344 if (case_insensitive && isupper(i_prime))\r
345 set_orel(tolower(i_prime)-MIN_CHAR,\r
346 &($$.label));\r
347 >>\r
348 { RANGE anychar\r
349 << if (case_insensitive){\r
350 i_prime = $$.letter+MIN_CHAR;\r
351 $$.letter = (islower(i_prime) ?\r
352 toupper(i_prime) : i_prime)-MIN_CHAR;\r
353 i_prime = $2.letter+MIN_CHAR;\r
354 $2.letter = (islower(i_prime) ?\r
355 toupper(i_prime) : i_prime)-MIN_CHAR;\r
356 }\r
357 /* check to see if range okay */\r
358 {\r
359 int debugLetter1 = $$.letter;\r
360 int debugLetter2 = $2.letter;\r
361 }\r
362 if ($$.letter > $2.letter \r
363 && $2.letter != 0xff){ /* MR16 */\r
364 error("invalid range ", zzline);\r
365 }\r
366 for (i=$$.letter; i<= (int)$2.letter; ++i){\r
367 set_orel(i,&($$.label));\r
368 i_prime = i+MIN_CHAR;\r
369 if (case_insensitive && islower(i_prime))\r
370 set_orel(toupper(i_prime)-MIN_CHAR,\r
371 &($$.label));\r
372 if (case_insensitive && isupper(i_prime))\r
373 set_orel(tolower(i_prime)-MIN_CHAR,\r
374 &($$.label));\r
375 }\r
376 >>\r
377 }\r
378 ;\r
379\r
380atom : << register int i_prime;>>\r
381 anychar\r
382 <<$$.label = set_of($1.letter);\r
383 i_prime = $1.letter + MIN_CHAR;\r
384 if (case_insensitive && islower(i_prime))\r
385 set_orel(toupper(i_prime)-MIN_CHAR,\r
386 &($$.label));\r
387 if (case_insensitive && isupper(i_prime))\r
388 set_orel(tolower(i_prime)-MIN_CHAR,\r
389 &($$.label));\r
390 >>\r
391 ;\r
392\r
393anychar : REGCHAR <<$$.letter = $1.letter - MIN_CHAR;>>\r
394 | OCTAL_VALUE <<$$.letter = $1.letter - MIN_CHAR;>>\r
395 | HEX_VALUE <<$$.letter = $1.letter - MIN_CHAR;>>\r
396 | DEC_VALUE <<$$.letter = $1.letter - MIN_CHAR;>>\r
397 | TAB <<$$.letter = $1.letter - MIN_CHAR;>>\r
398 | NL <<$$.letter = $1.letter - MIN_CHAR;>>\r
399 | CR <<$$.letter = $1.letter - MIN_CHAR;>>\r
400 | BS <<$$.letter = $1.letter - MIN_CHAR;>>\r
401 | LIT <<$$.letter = $1.letter - MIN_CHAR;>>\r
402 /* NOTE: LEX_EOF is ALWAYS shifted to 0 = MIN_CHAR - MIN_CHAR*/\r
403 | L_EOF <<$$.letter = 0;>>\r
404 ;\r
405\r
406<</* empty action */>>\r
407\r
408#lexclass ACT\r
409#token "@" << error("unterminated action", zzline); zzmode(START); >>\r
410#token ACTION "\>\>"\r
411 << if (func_action) fprintf(OUT,"}\n\n");\r
412 zzmode(START);\r
413/* MR1 */\r
414/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */\r
415/* MR1 via <<%%lexmember ...>> */\r
416/* MR1 This is a consequence of not saving actions */\r
417/* MR1 */\r
418/* MR1 */ parserClass=0; \r
419/* MR1 */ lexPrefix=0;\r
420/* MR1 */ lexAction=0;\r
421/* MR1 */ lexMember=0;\r
422 >>\r
423#token "\>" << xxputc(zzlextext[0]); zzskip(); >> /* MR1 */\r
424#token "\\\>" << xxputc('>'); zzskip(); >> /* MR1 */\r
425#token "\\" << xxputc('\\'); zzskip(); >> /* MR1 */\r
426#token "\n" << xxputc(zzlextext[0]); ++zzline; zzskip(); >> /* MR1 */\r
427#token "/\*" << zzmode(ACTION_COMMENTS); /* MR1 */\r
428 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
429 >> /* MR1 */\r
430#token "//" << zzmode(ACTION_CPP_COMMENTS); /* MR1 */\r
431 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
432 >> /* MR1 */\r
433#token "~[]" << xxputc(zzlextext[0]); zzskip(); >> /* MR1 */\r
434 /* MR1 */\r
435#lexclass ACTION_COMMENTS /* MR1 */\r
436#token "\*/" << zzmode(ACT); /* MR1 */\r
437 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
438 >> /* MR1 */\r
439#token "[\n\r]" << zzline++; xxputc(zzlextext[0]); zzskip();>> /* MR1 */\r
440#token "~[]" << xxputc(zzlextext[0]); zzskip();>> /* MR1 */\r
441 /* MR1 */\r
442#lexclass ACTION_CPP_COMMENTS /* MR1 */\r
443#token "[\n\r]" << zzmode(ACT); zzline++; /* MR1 */\r
444 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
445 >> /* MR1 */\r
446#token "~[]" << xxputc(zzlextext[0]); zzskip();>> /* MR1 */\r
447\r
448<<\r
449/* adds a new nfa to the binary tree and returns a pointer to it */\r
450nfa_node *\r
451#ifdef __USE_PROTOS\r
452new_nfa_node(void)\r
453#else\r
454new_nfa_node()\r
455#endif\r
456{\r
457 register nfa_node *t;\r
458 static int nfa_size=0; /* elements nfa_array[] can hold */\r
459\r
460 ++nfa_allocated;\r
461 if (nfa_size<=nfa_allocated){\r
462 /* need to redo array */\r
463 if (!nfa_array){\r
464 /* need some to do inital allocation */\r
465 nfa_size=nfa_allocated+NFA_MIN;\r
466 nfa_array=(nfa_node **) malloc(sizeof(nfa_node*)*\r
467 nfa_size);\r
468 }else{\r
469 /* need more space */\r
470 nfa_size=2*(nfa_allocated+1);\r
471 nfa_array=(nfa_node **) realloc(nfa_array,\r
472 sizeof(nfa_node*)*nfa_size);\r
473 }\r
474 }\r
475 /* fill out entry in array */\r
476 t = (nfa_node*) malloc(sizeof(nfa_node));\r
477 nfa_array[nfa_allocated] = t;\r
478 *t = nfa_model_node;\r
479 t->node_no = nfa_allocated;\r
480 return t;\r
481}\r
482\r
483\r
484/* initialize the model node used to fill in newly made nfa_nodes */\r
485void\r
486#ifdef __USE_PROTOS\r
487make_nfa_model_node(void)\r
488#else\r
489make_nfa_model_node()\r
490#endif\r
491{\r
492 nfa_model_node.node_no = -1; /* impossible value for real nfa node */\r
493 nfa_model_node.nfa_set = 0;\r
494 nfa_model_node.accept = 0; /* error state default*/\r
495 nfa_model_node.trans[0] = NULL;\r
496 nfa_model_node.trans[1] = NULL;\r
497 nfa_model_node.label = empty;\r
498}\r
499>>\r
500\r
501<<\r
502#if defined(DEBUG) || defined(_DEBUG)\r
503\r
504/* print out the pointer value and the node_number */\r
505void\r
506#ifdef __USE_PROTOS\r
507fprint_dfa_pair(FILE *f, nfa_node *p)\r
508#else\r
509fprint_dfa_pair(f, p)\r
510FILE *f;\r
511nfa_node *p;\r
512#endif\r
513{\r
514 if (p){\r
515 fprintf(f, "%x (%d)", p, p->node_no);\r
516 }else{\r
517 fprintf(f, "(nil)");\r
518 }\r
519}\r
520\r
521/* print out interest information on a set */\r
522void\r
523#ifdef __USE_PROTOS\r
524fprint_set(FILE *f, set s)\r
525#else\r
526fprint_set(f,s)\r
527FILE *f;\r
528set s;\r
529#endif\r
530{\r
531 unsigned int *x;\r
532\r
533 fprintf(f, "n = %d,", s.n);\r
534 if (s.setword){\r
535 fprintf(f, "setword = %x, ", s.setword);\r
536 /* print out all the elements in the set */\r
537 x = set_pdq(s);\r
538 while (*x!=nil){\r
539 fprintf(f, "%d ", *x);\r
540 ++x;\r
541 }\r
542 }else{\r
543 fprintf(f, "setword = (nil)");\r
544 }\r
545}\r
546\r
547/* code to be able to dump out the nfas\r
548 return 0 if okay dump\r
549 return 1 if screwed up\r
550 */\r
551int\r
552#ifdef __USE_PROTOS\r
553dump_nfas(int first_node, int last_node)\r
554#else\r
555dump_nfas(first_node, last_node)\r
556int first_node;\r
557int last_node;\r
558#endif\r
559{\r
560 register int i;\r
561 nfa_node *t;\r
562\r
563 for (i=first_node; i<=last_node; ++i){\r
564 t = NFA(i);\r
565 if (!t) break;\r
566 fprintf(stderr, "nfa_node %d {\n", t->node_no);\r
567 fprintf(stderr, "\n\tnfa_set = %d\n", t->nfa_set);\r
568 fprintf(stderr, "\taccept\t=\t%d\n", t->accept);\r
569 fprintf(stderr, "\ttrans\t=\t(");\r
570 fprint_dfa_pair(stderr, t->trans[0]);\r
571 fprintf(stderr, ",");\r
572 fprint_dfa_pair(stderr, t->trans[1]);\r
573 fprintf(stderr, ")\n");\r
574 fprintf(stderr, "\tlabel\t=\t{ ");\r
575 fprint_set(stderr, t->label);\r
576 fprintf(stderr, "\t}\n");\r
577 fprintf(stderr, "}\n\n");\r
578 }\r
579 return 0;\r
580}\r
581#endif\r
582>>\r
583\r
584<<\r
585/* DLG-specific syntax error message generator\r
586 * (define USER_ZZSYN when compiling so don't get 2 definitions)\r
587 */\r
588void\r
589#ifdef __USE_PROTOS\r
590zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
591#else\r
592zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
593char *text, *egroup, *bad_text;\r
594int tok;\r
595int etok;\r
596int k;\r
597SetWordType *eset;\r
598#endif\r
599{\r
600 fprintf(stderr, ErrHdr, file_str[0]!=NULL?file_str[0]:"stdin", zzline);\r
601 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
602 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
603 if ( k==1 ) fprintf(stderr, " missing");\r
604 else\r
605 {\r
606 fprintf(stderr, "; \"%s\" not", bad_text);\r
607 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
608 }\r
609 if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
610 else fprintf(stderr, " %s", zztokens[etok]);\r
611 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
612 fprintf(stderr, "\n");\r
613}\r
614>>\r