2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: frozen.tt_trace_gram.c /main/3 1995/10/23 10:35:40 rswiston $ */
25 # line 16 "util/tt_trace_gram.y"
31 * Copyright (c) 1993 by Sun Microsystems, Inc.
37 #include <sys/param.h>
39 extern int _tt_trace_iserr; /* declared in tt_trace_parser.cc */
41 static int wrapped = 0;
42 static int parsed = 0;
46 extern void _tt_process_follow(int);
47 extern void _tt_process_sink(char*, int);
48 extern void _tt_clear_functions(void);
49 extern int _tt_process_functionlist(char*);
50 extern void _tt_process_functions_allnone(int);
51 extern void _tt_process_attributes(int);
52 extern void _tt_clear_states(void);
53 extern int _tt_process_state(int, int);
54 extern void _tt_create_op_list(char*);
55 extern void _tt_add_op(char*);
56 extern void _tt_create_sp_list(char*);
57 extern void _tt_add_sender_ptype(char*);
58 extern void _tt_create_hp_list(char*);
59 extern void _tt_add_handler_ptype(char*);
64 # line 59 "util/tt_trace_gram.y"
71 char string[MAXPATHLEN];
78 # define _TT_TRACE_FOLLOW 257
79 # define _TT_TRACE_SINK 258
80 # define _TT_TRACE_SINK_APPEND 259
81 # define _TT_TRACE_FUNCTIONS 260
82 # define _TT_TRACE_ATTRIBUTES 261
83 # define _TT_TRACE_STATES 262
84 # define _TT_TRACE_OPS 263
85 # define _TT_TRACE_SENDER_PTYPES 264
86 # define _TT_TRACE_HANDLER_PTYPES 265
87 # define _TT_TRACE_ON 266
88 # define _TT_TRACE_OFF 267
89 # define _TT_TRACE_ALL 268
90 # define _TT_TRACE_NONE 269
91 # define _TT_TRACE_STATES_NEDD 270
92 # define _TT_TRACE_STATES_TT 271
93 # define _TT_TRACE_EDGE 272
94 # define _TT_TRACE_DELIVER 273
95 # define _TT_TRACE_DISPATCH 274
96 # define _TT_TRACE_VERSION 275
97 # define _TT_TRACE_IVAL 276
98 # define _TT_TRACE_STATES_VAL 277
99 # define _TT_TRACE_ALPHANUM 278
100 # define _TT_TRACE_FILENAME 279
101 # define _TT_TRACE_LINETERM 280
102 # define _TT_TRACE_PARSE_EOF 281
110 #ifndef tt_trace_error
111 void tt_trace_error(const char *);
116 extern "C" { int tt_trace_lex(void); }
118 int tt_trace_lex(void);
121 int tt_trace_parse(void);
124 #define tt_trace_clearin tt_trace_char = -1
125 #define tt_trace_errok tt_trace_errflag = 0
126 extern int tt_trace_char;
127 extern int tt_trace_errflag;
128 TT_TRACE_STYPE tt_trace_lval;
129 TT_TRACE_STYPE tt_trace_val;
130 typedef int tt_trace_tabelem;
131 #ifndef TT_TRACE_MAXDEPTH
132 #define TT_TRACE_MAXDEPTH 150
134 #if TT_TRACE_MAXDEPTH > 0
135 int tt_trace__tt_trace_s[TT_TRACE_MAXDEPTH], *tt_trace_s = tt_trace__tt_trace_s;
136 TT_TRACE_STYPE tt_trace__tt_trace_v[TT_TRACE_MAXDEPTH], *tt_trace_v = tt_trace__tt_trace_v;
137 #else /* user does initial allocation */
139 TT_TRACE_STYPE *tt_trace_v;
141 static int tt_trace_maxdepth = TT_TRACE_MAXDEPTH;
142 # define TT_TRACE_ERRCODE 256
144 # line 250 "util/tt_trace_gram.y"
150 tt_trace_error(char* s)
155 * _tt_trace_iserr is set before explicit calls to
156 * tt_trace_error. If its value is still zero, then
157 * YACC called this routine because of a syntax error.
160 fprintf(stderr, "%s\n", s);
161 if (!_tt_trace_iserr) _tt_trace_iserr = 1;
171 tt_trace_tabelem tt_trace_exca[] ={
176 # define TT_TRACE_NPROD 40
177 # define TT_TRACE_LAST 61
178 tt_trace_tabelem tt_trace_act[]={
180 13, 14, 15, 16, 18, 28, 25, 26, 27, 40,
181 39, 60, 46, 41, 47, 44, 59, 45, 12, 42,
182 36, 43, 37, 11, 58, 57, 56, 55, 54, 34,
183 33, 32, 31, 53, 29, 52, 51, 50, 49, 38,
184 48, 35, 30, 22, 21, 20, 19, 24, 17, 23,
185 10, 9, 8, 7, 6, 5, 4, 3, 2, -1,
187 tt_trace_tabelem tt_trace_pact[]={
189 -10000000, -257,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,
190 -10000000,-10000000, -246, -234, -247, -249, -235, -258, -237, -267,
191 -259, -263, -266, -238, -239, -242, -243, -245,-10000000,-10000000,
192 -252, -253, -254, -255, -256, -264,-10000000,-10000000, -269,-10000000,
193 -10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,
194 -10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,
196 tt_trace_tabelem tt_trace_pgo[]={
198 0, 60, 59, 58, 57, 56, 55, 54, 53, 52,
199 51, 50, 49, 48, 47, 46, 45, 44, 43 };
200 tt_trace_tabelem tt_trace_r1[]={
202 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
203 1, 1, 1, 3, 4, 5, 5, 5, 5, 12,
204 13, 13, 6, 6, 7, 14, 15, 15, 15, 15,
205 8, 16, 16, 9, 17, 17, 10, 18, 18, 11 };
206 tt_trace_tabelem tt_trace_r2[]={
208 0, 5, 0, 5, 5, 5, 5, 5, 5, 5,
209 5, 5, 4, 4, 7, 7, 7, 7, 7, 3,
210 5, 5, 7, 4, 7, 3, 5, 5, 5, 5,
211 4, 5, 5, 4, 5, 5, 4, 5, 5, 4 };
212 tt_trace_tabelem tt_trace_chk[]={
214 -10000000, -1, -3, -4, -5, -6, -7, -8, -9, -10,
215 -11, 280, 275, 257, 258, 259, 260, -13, 261, -15,
216 -16, -17, -18, -12, -14, 263, 264, 265, 262, 280,
217 276, 279, 278, 279, 278, 276, 278, 280, 276, 277,
218 276, 280, 278, 280, 278, 280, 278, 280, 278, 277,
219 276, 278, 278, 278, 280, 280, 280, 280, 280, 280,
221 tt_trace_tabelem tt_trace_def[]={
223 2, -2, 3, 4, 5, 6, 7, 8, 9, 10,
224 11, 12, 0, 0, 0, 0, 19, 0, 0, 0,
225 0, 0, 0, 0, 0, 0, 0, 0, 25, 13,
226 0, 0, 0, 0, 0, 0, 21, 23, 0, 27,
227 29, 30, 32, 33, 35, 36, 38, 39, 20, 26,
228 28, 31, 34, 37, 14, 15, 17, 16, 18, 22,
234 { char *t_name; int t_val; } tt_trace_toktype;
235 #ifndef TT_TRACE_DEBUG
236 # define TT_TRACE_DEBUG 0 /* don't allow debugging */
241 tt_trace_toktype tt_trace_toks[] =
243 "_TT_TRACE_FOLLOW", 257,
244 "_TT_TRACE_SINK", 258,
245 "_TT_TRACE_SINK_APPEND", 259,
246 "_TT_TRACE_FUNCTIONS", 260,
247 "_TT_TRACE_ATTRIBUTES", 261,
248 "_TT_TRACE_STATES", 262,
249 "_TT_TRACE_OPS", 263,
250 "_TT_TRACE_SENDER_PTYPES", 264,
251 "_TT_TRACE_HANDLER_PTYPES", 265,
253 "_TT_TRACE_OFF", 267,
254 "_TT_TRACE_ALL", 268,
255 "_TT_TRACE_NONE", 269,
256 "_TT_TRACE_STATES_NEDD", 270,
257 "_TT_TRACE_STATES_TT", 271,
258 "_TT_TRACE_EDGE", 272,
259 "_TT_TRACE_DELIVER", 273,
260 "_TT_TRACE_DISPATCH", 274,
261 "_TT_TRACE_VERSION", 275,
262 "_TT_TRACE_IVAL", 276,
263 "_TT_TRACE_STATES_VAL", 277,
264 "_TT_TRACE_ALPHANUM", 278,
265 "_TT_TRACE_FILENAME", 279,
266 "_TT_TRACE_LINETERM", 280,
267 "_TT_TRACE_PARSE_EOF", 281,
268 "-unknown-", -1 /* ends search */
271 char * tt_trace_reds[] =
273 "-no such reduction-",
274 "finish : list _TT_TRACE_PARSE_EOF",
275 "list : /* empty */",
276 "list : list version_list",
277 "list : list follow_list",
278 "list : list sink_list",
279 "list : list functions_list",
280 "list : list attributes_list",
281 "list : list states_list",
282 "list : list ops_list",
283 "list : list sender_ptypes_list",
284 "list : list handler_ptypes_list",
285 "list : list _TT_TRACE_LINETERM",
286 "version_list : _TT_TRACE_VERSION _TT_TRACE_LINETERM",
287 "follow_list : _TT_TRACE_FOLLOW _TT_TRACE_IVAL _TT_TRACE_LINETERM",
288 "sink_list : _TT_TRACE_SINK _TT_TRACE_FILENAME _TT_TRACE_LINETERM",
289 "sink_list : _TT_TRACE_SINK_APPEND _TT_TRACE_FILENAME _TT_TRACE_LINETERM",
290 "sink_list : _TT_TRACE_SINK _TT_TRACE_ALPHANUM _TT_TRACE_LINETERM",
291 "sink_list : _TT_TRACE_SINK_APPEND _TT_TRACE_ALPHANUM _TT_TRACE_LINETERM",
292 "functionkywrd : _TT_TRACE_FUNCTIONS",
293 "functionlist : functionkywrd _TT_TRACE_ALPHANUM",
294 "functionlist : functionlist _TT_TRACE_ALPHANUM",
295 "functions_list : _TT_TRACE_FUNCTIONS _TT_TRACE_IVAL _TT_TRACE_LINETERM",
296 "functions_list : functionlist _TT_TRACE_LINETERM",
297 "attributes_list : _TT_TRACE_ATTRIBUTES _TT_TRACE_IVAL _TT_TRACE_LINETERM",
298 "stateskywrd : _TT_TRACE_STATES",
299 "stateslist : stateskywrd _TT_TRACE_STATES_VAL",
300 "stateslist : stateslist _TT_TRACE_STATES_VAL",
301 "stateslist : stateskywrd _TT_TRACE_IVAL",
302 "stateslist : stateslist _TT_TRACE_IVAL",
303 "states_list : stateslist _TT_TRACE_LINETERM",
304 "oplist : _TT_TRACE_OPS _TT_TRACE_ALPHANUM",
305 "oplist : oplist _TT_TRACE_ALPHANUM",
306 "ops_list : oplist _TT_TRACE_LINETERM",
307 "senderptypeslist : _TT_TRACE_SENDER_PTYPES _TT_TRACE_ALPHANUM",
308 "senderptypeslist : senderptypeslist _TT_TRACE_ALPHANUM",
309 "sender_ptypes_list : senderptypeslist _TT_TRACE_LINETERM",
310 "handlerptypeslist : _TT_TRACE_HANDLER_PTYPES _TT_TRACE_ALPHANUM",
311 "handlerptypeslist : handlerptypeslist _TT_TRACE_ALPHANUM",
312 "handler_ptypes_list : handlerptypeslist _TT_TRACE_LINETERM",
314 #endif /* TT_TRACE_DEBUG */
316 * Copyright (c) 1993 by Sun Microsystems, Inc.
319 #pragma ident "@(#)yaccpar 6.12 93/06/07 SMI"
322 ** Skeleton parser driver for yacc output
326 ** yacc user known macros and defines
328 #define TT_TRACE_ERROR goto tt_trace_errlab
329 #define TT_TRACE_ACCEPT return(0)
330 #define TT_TRACE_ABORT return(1)
331 #define TT_TRACE_BACKUP( newtoken, newvalue )\
333 if ( tt_trace_char >= 0 || ( tt_trace_r2[ tt_trace_tmp ] >> 1 ) != 1 )\
335 tt_trace_error( "syntax error - cannot backup" );\
336 goto tt_trace_errlab;\
338 tt_trace_char = newtoken;\
339 tt_trace_state = *tt_trace_ps;\
340 tt_trace_lval = newvalue;\
341 goto tt_trace_newstate;\
343 #define TT_TRACE_RECOVERING() (!!tt_trace_errflag)
344 #define TT_TRACE_NEW(type) malloc(sizeof(type) * tt_trace_newmax)
345 #define TT_TRACE_COPY(to, from, type) \
346 (type *) memcpy(to, (char *) from, tt_trace_newmax * sizeof(type))
347 #define TT_TRACE_ENLARGE( from, type) \
348 (type *) realloc((char *) from, tt_trace_newmax * sizeof(type))
349 #ifndef TT_TRACE_DEBUG
350 # define TT_TRACE_DEBUG 1 /* make debugging available */
354 ** user known globals
356 int tt_trace_debug; /* set to 1 to get debugging */
359 ** driver internal defines
361 #define TT_TRACE_FLAG (-10000000)
364 ** global variables used by the parser
366 TT_TRACE_STYPE *tt_trace_pv; /* top of value stack */
367 int *tt_trace_ps; /* top of state stack */
369 int tt_trace_state; /* current state */
370 int tt_trace_tmp; /* extra var (lasts between blocks) */
372 int tt_trace_nerrs; /* number of errors */
373 int tt_trace_errflag; /* error recovery flag */
374 int tt_trace_char; /* current input token number */
378 #ifdef TT_TRACE_NMBCHARS
379 #define TT_TRACE_LEX() tt_trace_cvtok(tt_trace_lex())
381 ** tt_trace_cvtok - return a token if i is a wchar_t value that exceeds 255.
382 ** If i<255, i itself is the token. If i>255 but the neither
383 ** of the 30th or 31st bit is on, i is already a token.
385 #if defined(__STDC__) || defined(__cplusplus)
386 int tt_trace_cvtok(int i)
388 int tt_trace_cvtok(i) int i;
392 int last = TT_TRACE_NMBCHARS - 1;
396 if(i&0x60000000){/*Must convert to a token. */
397 if( tt_trace_mbchars[last].character < i ){
398 return i;/*Giving up*/
400 while ((last>=first)&&(first>=0)) {/*Binary search loop*/
401 mid = (first+last)/2;
402 j = tt_trace_mbchars[mid].character;
404 return tt_trace_mbchars[mid].tvalue;
411 /*No entry in the table.*/
412 return i;/* Giving up.*/
413 }else{/* i is already a token. */
417 #else/*!TT_TRACE_NMBCHARS*/
418 #define TT_TRACE_LEX() tt_trace_lex()
419 #endif/*!TT_TRACE_NMBCHARS*/
422 ** tt_trace_parse - return 0 if worked, 1 if syntax error not recovered from
424 #if defined(__STDC__) || defined(__cplusplus)
425 int tt_trace_parse(void)
430 register TT_TRACE_STYPE *tt_trace_pvt; /* top of value stack for $vars */
432 #if defined(__cplusplus) || defined(lint)
434 hacks to please C++ and lint - goto's inside switch should never be
435 executed; tt_trace_pvt is set to 0 to avoid "used before set" warning.
437 static int __yaccpar_lint_hack__ = 0;
438 switch (__yaccpar_lint_hack__)
440 case 1: goto tt_trace_errlab;
441 case 2: goto tt_trace_newstate;
447 ** Initialize externals - tt_trace_parse may be called more than once
449 tt_trace_pv = &tt_trace_v[-1];
450 tt_trace_ps = &tt_trace_s[-1];
454 tt_trace_errflag = 0;
457 #if TT_TRACE_MAXDEPTH <= 0
458 if (tt_trace_maxdepth <= 0)
460 if ((tt_trace_maxdepth = TT_TRACE_EXPAND(0)) <= 0)
462 tt_trace_error("yacc initialization error");
469 register TT_TRACE_STYPE *tt_trace__pv; /* top of value stack */
470 register int *tt_trace__ps; /* top of state stack */
471 register int tt_trace__state; /* current state */
472 register int tt_trace__n; /* internal state number info */
473 goto tt_trace_stack; /* moved from 6 lines above to here to please C++ */
476 ** get globals into registers.
477 ** branch to here only if TT_TRACE_BACKUP was called.
480 tt_trace__pv = tt_trace_pv;
481 tt_trace__ps = tt_trace_ps;
482 tt_trace__state = tt_trace_state;
483 goto tt_trace__newstate;
486 ** get globals into registers.
487 ** either we just started, or we just finished a reduction
490 tt_trace__pv = tt_trace_pv;
491 tt_trace__ps = tt_trace_ps;
492 tt_trace__state = tt_trace_state;
495 ** top of for (;;) loop while no reductions done
499 ** put a state and value onto the stacks
503 ** if debugging, look up token value in list of value vs.
504 ** name pairs. 0 and negative (-1) are special values.
505 ** Note: linear search is used since time is not a real
506 ** consideration while debugging.
508 if ( tt_trace_debug )
510 register int tt_trace__i;
512 printf( "State %d, token ", tt_trace__state );
513 if ( tt_trace_char == 0 )
514 printf( "end-of-file\n" );
515 else if ( tt_trace_char < 0 )
516 printf( "-none-\n" );
519 for ( tt_trace__i = 0; tt_trace_toks[tt_trace__i].t_val >= 0;
522 if ( tt_trace_toks[tt_trace__i].t_val == tt_trace_char )
525 printf( "%s\n", tt_trace_toks[tt_trace__i].t_name );
528 #endif /* TT_TRACE_DEBUG */
529 if ( ++tt_trace__ps >= &tt_trace_s[ tt_trace_maxdepth ] ) /* room on stack? */
532 ** reallocate and recover. Note that pointers
533 ** have to be reset, or bad things will happen
535 int tt_trace_ps_index = (tt_trace__ps - tt_trace_s);
536 int tt_trace_pv_index = (tt_trace__pv - tt_trace_v);
537 int tt_trace_pvt_index = (tt_trace_pvt - tt_trace_v);
539 #ifdef TT_TRACE_EXPAND
540 tt_trace_newmax = TT_TRACE_EXPAND(tt_trace_maxdepth);
542 tt_trace_newmax = 2 * tt_trace_maxdepth; /* double table size */
543 if (tt_trace_maxdepth == TT_TRACE_MAXDEPTH) /* first time growth */
545 char *newtt_trace_s = (char *)TT_TRACE_NEW(int);
546 char *newtt_trace_v = (char *)TT_TRACE_NEW(TT_TRACE_STYPE);
547 if (newtt_trace_s != 0 && newtt_trace_v != 0)
549 tt_trace_s = TT_TRACE_COPY(newtt_trace_s, tt_trace_s, int);
550 tt_trace_v = TT_TRACE_COPY(newtt_trace_v, tt_trace_v, TT_TRACE_STYPE);
553 tt_trace_newmax = 0; /* failed */
555 else /* not first time */
557 tt_trace_s = TT_TRACE_ENLARGE(tt_trace_s, int);
558 tt_trace_v = TT_TRACE_ENLARGE(tt_trace_v, TT_TRACE_STYPE);
559 if (tt_trace_s == 0 || tt_trace_v == 0)
560 tt_trace_newmax = 0; /* failed */
563 if (tt_trace_newmax <= tt_trace_maxdepth) /* tables not expanded */
565 tt_trace_error( "yacc stack overflow" );
568 tt_trace_maxdepth = tt_trace_newmax;
570 tt_trace__ps = tt_trace_s + tt_trace_ps_index;
571 tt_trace__pv = tt_trace_v + tt_trace_pv_index;
572 tt_trace_pvt = tt_trace_v + tt_trace_pvt_index;
574 *tt_trace__ps = tt_trace__state;
575 *++tt_trace__pv = tt_trace_val;
578 ** we have a new state - find out what to do
581 if ( ( tt_trace__n = tt_trace_pact[ tt_trace__state ] ) <= TT_TRACE_FLAG )
582 goto tt_trace_default; /* simple state */
585 ** if debugging, need to mark whether new token grabbed
587 tt_trace_tmp = tt_trace_char < 0;
589 if ( ( tt_trace_char < 0 ) && ( ( tt_trace_char = TT_TRACE_LEX() ) < 0 ) )
590 tt_trace_char = 0; /* reached EOF */
592 if ( tt_trace_debug && tt_trace_tmp )
594 register int tt_trace__i;
596 printf( "Received token " );
597 if ( tt_trace_char == 0 )
598 printf( "end-of-file\n" );
599 else if ( tt_trace_char < 0 )
600 printf( "-none-\n" );
603 for ( tt_trace__i = 0; tt_trace_toks[tt_trace__i].t_val >= 0;
606 if ( tt_trace_toks[tt_trace__i].t_val == tt_trace_char )
609 printf( "%s\n", tt_trace_toks[tt_trace__i].t_name );
612 #endif /* TT_TRACE_DEBUG */
613 if ( ( ( tt_trace__n += tt_trace_char ) < 0 ) || ( tt_trace__n >= TT_TRACE_LAST ) )
614 goto tt_trace_default;
615 if ( tt_trace_chk[ tt_trace__n = tt_trace_act[ tt_trace__n ] ] == tt_trace_char ) /*valid shift*/
618 tt_trace_val = tt_trace_lval;
619 tt_trace__state = tt_trace__n;
620 if ( tt_trace_errflag > 0 )
622 goto tt_trace__stack;
626 if ( ( tt_trace__n = tt_trace_def[ tt_trace__state ] ) == -2 )
629 tt_trace_tmp = tt_trace_char < 0;
631 if ( ( tt_trace_char < 0 ) && ( ( tt_trace_char = TT_TRACE_LEX() ) < 0 ) )
632 tt_trace_char = 0; /* reached EOF */
634 if ( tt_trace_debug && tt_trace_tmp )
636 register int tt_trace__i;
638 printf( "Received token " );
639 if ( tt_trace_char == 0 )
640 printf( "end-of-file\n" );
641 else if ( tt_trace_char < 0 )
642 printf( "-none-\n" );
645 for ( tt_trace__i = 0;
646 tt_trace_toks[tt_trace__i].t_val >= 0;
649 if ( tt_trace_toks[tt_trace__i].t_val
655 printf( "%s\n", tt_trace_toks[tt_trace__i].t_name );
658 #endif /* TT_TRACE_DEBUG */
660 ** look through exception table
663 register int *tt_trace_xi = tt_trace_exca;
665 while ( ( *tt_trace_xi != -1 ) ||
666 ( tt_trace_xi[1] != tt_trace__state ) )
670 while ( ( *(tt_trace_xi += 2) >= 0 ) &&
671 ( *tt_trace_xi != tt_trace_char ) )
673 if ( ( tt_trace__n = tt_trace_xi[1] ) < 0 )
679 ** check for syntax error
681 if ( tt_trace__n == 0 ) /* have an error */
683 /* no worry about speed here! */
684 switch ( tt_trace_errflag )
686 case 0: /* new error */
687 tt_trace_error( "syntax error" );
691 ** get globals into registers.
692 ** we have a user generated syntax type error
694 tt_trace__pv = tt_trace_pv;
695 tt_trace__ps = tt_trace_ps;
696 tt_trace__state = tt_trace_state;
701 case 2: /* incompletely recovered error */
703 tt_trace_errflag = 3;
705 ** find state where "error" is a legal
708 while ( tt_trace__ps >= tt_trace_s )
710 tt_trace__n = tt_trace_pact[ *tt_trace__ps ] + TT_TRACE_ERRCODE;
711 if ( tt_trace__n >= 0 && tt_trace__n < TT_TRACE_LAST &&
712 tt_trace_chk[tt_trace_act[tt_trace__n]] == TT_TRACE_ERRCODE) {
714 ** simulate shift of "error"
716 tt_trace__state = tt_trace_act[ tt_trace__n ];
717 goto tt_trace__stack;
720 ** current state has no shift on
721 ** "error", pop stack
724 # define _POP_ "Error recovery pops state %d, uncovers state %d\n"
725 if ( tt_trace_debug )
726 printf( _POP_, *tt_trace__ps,
734 ** there is no state on stack with "error" as
735 ** a valid shift. give up.
738 case 3: /* no shift yet; eat a token */
741 ** if debugging, look up token in list of
742 ** pairs. 0 and negative shouldn't occur,
743 ** but since timing doesn't matter when
744 ** debugging, it doesn't hurt to leave the
747 if ( tt_trace_debug )
749 register int tt_trace__i;
751 printf( "Error recovery discards " );
752 if ( tt_trace_char == 0 )
753 printf( "token end-of-file\n" );
754 else if ( tt_trace_char < 0 )
755 printf( "token -none-\n" );
758 for ( tt_trace__i = 0;
759 tt_trace_toks[tt_trace__i].t_val >= 0;
762 if ( tt_trace_toks[tt_trace__i].t_val
768 printf( "token %s\n",
769 tt_trace_toks[tt_trace__i].t_name );
772 #endif /* TT_TRACE_DEBUG */
773 if ( tt_trace_char == 0 ) /* reached EOF. quit */
776 goto tt_trace__newstate;
778 }/* end if ( tt_trace__n == 0 ) */
780 ** reduction by production tt_trace__n
781 ** put stack tops, etc. so things right after switch
785 ** if debugging, print the string that is the user's
786 ** specification of the reduction which is just about
789 if ( tt_trace_debug )
790 printf( "Reduce by (%d) \"%s\"\n",
791 tt_trace__n, tt_trace_reds[ tt_trace__n ] );
793 tt_trace_tmp = tt_trace__n; /* value to switch over */
794 tt_trace_pvt = tt_trace__pv; /* $vars top of value stack */
796 ** Look in goto table for next state
797 ** Sorry about using tt_trace__state here as temporary
798 ** register variable, but why not, if it works...
799 ** If tt_trace_r2[ tt_trace__n ] doesn't have the low order bit
800 ** set, then there is no action to be done for
801 ** this reduction. So, no saving & unsaving of
802 ** registers done. The only difference between the
803 ** code just after the if and the body of the if is
804 ** the goto tt_trace__stack in the body. This way the test
805 ** can be made before the choice of what to do is needed.
808 /* length of production doubled with extra bit */
809 register int tt_trace__len = tt_trace_r2[ tt_trace__n ];
811 if ( !( tt_trace__len & 01 ) )
814 tt_trace_val = ( tt_trace__pv -= tt_trace__len )[1]; /* $$ = $1 */
815 tt_trace__state = tt_trace_pgo[ tt_trace__n = tt_trace_r1[ tt_trace__n ] ] +
816 *( tt_trace__ps -= tt_trace__len ) + 1;
817 if ( tt_trace__state >= TT_TRACE_LAST ||
818 tt_trace_chk[ tt_trace__state =
819 tt_trace_act[ tt_trace__state ] ] != -tt_trace__n )
821 tt_trace__state = tt_trace_act[ tt_trace_pgo[ tt_trace__n ] ];
823 goto tt_trace__stack;
826 tt_trace_val = ( tt_trace__pv -= tt_trace__len )[1]; /* $$ = $1 */
827 tt_trace__state = tt_trace_pgo[ tt_trace__n = tt_trace_r1[ tt_trace__n ] ] +
828 *( tt_trace__ps -= tt_trace__len ) + 1;
829 if ( tt_trace__state >= TT_TRACE_LAST ||
830 tt_trace_chk[ tt_trace__state = tt_trace_act[ tt_trace__state ] ] != -tt_trace__n )
832 tt_trace__state = tt_trace_act[ tt_trace_pgo[ tt_trace__n ] ];
835 /* save until reenter driver code */
836 tt_trace_state = tt_trace__state;
837 tt_trace_ps = tt_trace__ps;
838 tt_trace_pv = tt_trace__pv;
841 ** code supplied by user is placed in this switch
843 switch( tt_trace_tmp )
847 # line 97 "util/tt_trace_gram.y"
857 # line 107 "util/tt_trace_gram.y"
858 { parsed = 1; wrapped = 0; } break;
860 # line 108 "util/tt_trace_gram.y"
861 { parsed = 1; wrapped = 0; } break;
863 # line 109 "util/tt_trace_gram.y"
864 { parsed = 1; wrapped = 0; } break;
866 # line 110 "util/tt_trace_gram.y"
867 { parsed = 1; wrapped = 0; } break;
869 # line 111 "util/tt_trace_gram.y"
870 { parsed = 1; wrapped = 0; } break;
872 # line 112 "util/tt_trace_gram.y"
873 { parsed = 1; wrapped = 0; } break;
875 # line 113 "util/tt_trace_gram.y"
876 { parsed = 1; wrapped = 0; } break;
878 # line 114 "util/tt_trace_gram.y"
879 { parsed = 1; wrapped = 0; } break;
881 # line 115 "util/tt_trace_gram.y"
882 { parsed = 1; wrapped = 0; } break;
884 # line 123 "util/tt_trace_gram.y"
885 { _tt_process_follow(tt_trace_pvt[-1].tokenval); } break;
887 # line 127 "util/tt_trace_gram.y"
888 { _tt_process_sink(tt_trace_pvt[-1].string, O_RDWR | O_CREAT); } break;
890 # line 129 "util/tt_trace_gram.y"
891 { _tt_process_sink(tt_trace_pvt[-1].string, O_APPEND | O_CREAT); } break;
893 # line 137 "util/tt_trace_gram.y"
894 { _tt_process_sink(tt_trace_pvt[-1].string, O_RDWR | O_CREAT); } break;
896 # line 139 "util/tt_trace_gram.y"
897 { _tt_process_sink(tt_trace_pvt[-1].string, O_APPEND | O_CREAT); } break;
899 # line 143 "util/tt_trace_gram.y"
900 { _tt_clear_functions(); } break;
902 # line 147 "util/tt_trace_gram.y"
903 { _tt_process_functionlist(tt_trace_pvt[-0].string); } break;
905 # line 149 "util/tt_trace_gram.y"
906 { _tt_process_functionlist(tt_trace_pvt[-0].string); } break;
908 # line 153 "util/tt_trace_gram.y"
910 all = (tt_trace_pvt[-1].tokenval == _TT_TRACE_ALL ? 1 : 0);
911 _tt_process_functions_allnone(all);
914 # line 161 "util/tt_trace_gram.y"
916 all = (tt_trace_pvt[-1].tokenval == _TT_TRACE_ALL ? 1 : 0);
917 _tt_process_attributes(tt_trace_pvt[-1].tokenval);
920 # line 170 "util/tt_trace_gram.y"
921 { _tt_clear_states(); } break;
923 # line 173 "util/tt_trace_gram.y"
925 /* process_states can't fail here because the
926 * grammar ensures that this is the first
929 (void) _tt_process_state(tt_trace_pvt[-0].stateval.state_type,
930 tt_trace_pvt[-0].stateval.state_val);
933 # line 182 "util/tt_trace_gram.y"
935 if (!_tt_process_state(tt_trace_pvt[-0].stateval.state_type,
936 tt_trace_pvt[-0].stateval.state_val)) {
938 tt_trace_error("Can't mix none with other state values");
942 # line 190 "util/tt_trace_gram.y"
944 /* process_states can't fail here because the
945 * grammar ensures that this is the first
949 if (tt_trace_pvt[-0].tokenval == _TT_TRACE_NONE) {
950 _tt_process_state(_TT_TRACE_STATES_NEDD,
953 else { /* Syntax error */
955 tt_trace_error("Bad value for state");
959 # line 206 "util/tt_trace_gram.y"
961 if (tt_trace_pvt[-0].tokenval == _TT_TRACE_NONE) {
962 if (!_tt_process_state(_TT_TRACE_STATES_NEDD,
965 tt_trace_error("Can't mix none with other state values");
968 else { /* Syntax error */
970 tt_trace_error("Bad value for state");
974 # line 227 "util/tt_trace_gram.y"
975 { _tt_create_op_list(tt_trace_pvt[-0].string); } break;
977 # line 229 "util/tt_trace_gram.y"
978 { _tt_add_op(tt_trace_pvt[-0].string); } break;
980 # line 235 "util/tt_trace_gram.y"
981 { _tt_create_sp_list(tt_trace_pvt[-0].string); } break;
983 # line 237 "util/tt_trace_gram.y"
984 { _tt_add_sender_ptype(tt_trace_pvt[-0].string); } break;
986 # line 243 "util/tt_trace_gram.y"
987 { _tt_create_hp_list(tt_trace_pvt[-0].string); } break;
989 # line 245 "util/tt_trace_gram.y"
990 { _tt_add_handler_ptype(tt_trace_pvt[-0].string); } break;
992 goto tt_trace_stack; /* reset registers in driver code */