tt/lib: remove register keyword
[oweals/cde.git] / cde / lib / tt / lib / util / frozen.tt_trace_gram.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: frozen.tt_trace_gram.c /main/3 1995/10/23 10:35:40 rswiston $ */
24
25 # line 16 "util/tt_trace_gram.y"
26
27 /*
28  *
29  * tt_trace_gram.y
30  *
31  * Copyright (c) 1993 by Sun Microsystems, Inc.
32  */
33  
34 #include <stdio.h>
35 #include <string.h>
36 #include <fcntl.h>
37 #include <sys/param.h>
38
39 extern int _tt_trace_iserr;     /* declared in tt_trace_parser.cc */
40
41 static int wrapped = 0;
42 static int parsed = 0;
43 static int ret = 0;
44 static int all = 0;
45
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*);
60
61 \f
62
63
64 # line 59 "util/tt_trace_gram.y"
65 typedef union
66 #ifdef __cplusplus
67         TT_TRACE_STYPE
68 #endif
69  {
70         char    special;
71         char    string[MAXPATHLEN];
72         int             tokenval;
73         struct {
74                 int state_type;
75                 int state_val;
76         } stateval;
77 } TT_TRACE_STYPE;
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
103
104 #include <stdlib.h>
105 #include <memory.h>
106 #include <values.h>
107
108 #ifdef __cplusplus
109
110 #ifndef tt_trace_error
111         void tt_trace_error(const char *);
112 #endif
113
114 #ifndef tt_trace_lex
115 #ifdef __EXTERN_C__
116         extern "C" { int tt_trace_lex(void); }
117 #else
118         int tt_trace_lex(void);
119 #endif
120 #endif
121         int tt_trace_parse(void);
122
123 #endif
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
133 #endif
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 */
138 int *tt_trace_s;
139 TT_TRACE_STYPE *tt_trace_v;
140 #endif
141 static int tt_trace_maxdepth = TT_TRACE_MAXDEPTH;
142 # define TT_TRACE_ERRCODE 256
143
144 # line 250 "util/tt_trace_gram.y"
145
146
147 \f
148
149 void
150 tt_trace_error(char* s)
151 {
152         if (!wrapped) {
153
154                 /*
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.
158                  */
159
160                 fprintf(stderr, "%s\n", s);
161                 if (!_tt_trace_iserr) _tt_trace_iserr = 1;
162         }
163 }
164
165 int
166 tt_trace_wrap()
167 {
168         wrapped = 1;
169         return 1;
170 }
171 tt_trace_tabelem tt_trace_exca[] ={
172 -1, 1,
173         0, -1,
174         -2, 0,
175         };
176 # define TT_TRACE_NPROD 40
177 # define TT_TRACE_LAST 61
178 tt_trace_tabelem tt_trace_act[]={
179
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,
186      1 };
187 tt_trace_tabelem tt_trace_pact[]={
188
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,
195 -10000000 };
196 tt_trace_tabelem tt_trace_pgo[]={
197
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[]={
201
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[]={
207
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[]={
213
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,
220    280 };
221 tt_trace_tabelem tt_trace_def[]={
222
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,
229     24 };
230 typedef struct
231 #ifdef __cplusplus
232         tt_trace_toktype
233 #endif
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 */
237 #endif
238
239 #if TT_TRACE_DEBUG
240
241 tt_trace_toktype tt_trace_toks[] =
242 {
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,
252         "_TT_TRACE_ON", 266,
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 */
269 };
270
271 char * tt_trace_reds[] =
272 {
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",
313 };
314 #endif /* TT_TRACE_DEBUG */
315 /*
316  * Copyright (c) 1993 by Sun Microsystems, Inc.
317  */
318
319 #pragma ident   "@(#)yaccpar    6.12    93/06/07 SMI"
320
321 /*
322 ** Skeleton parser driver for yacc output
323 */
324
325 /*
326 ** yacc user known macros and defines
327 */
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 )\
332 {\
333         if ( tt_trace_char >= 0 || ( tt_trace_r2[ tt_trace_tmp ] >> 1 ) != 1 )\
334         {\
335                 tt_trace_error( "syntax error - cannot backup" );\
336                 goto tt_trace_errlab;\
337         }\
338         tt_trace_char = newtoken;\
339         tt_trace_state = *tt_trace_ps;\
340         tt_trace_lval = newvalue;\
341         goto tt_trace_newstate;\
342 }
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 */
351 #endif
352
353 /*
354 ** user known globals
355 */
356 int tt_trace_debug;                     /* set to 1 to get debugging */
357
358 /*
359 ** driver internal defines
360 */
361 #define TT_TRACE_FLAG           (-10000000)
362
363 /*
364 ** global variables used by the parser
365 */
366 TT_TRACE_STYPE *tt_trace_pv;                    /* top of value stack */
367 int *tt_trace_ps;                       /* top of state stack */
368
369 int tt_trace_state;                     /* current state */
370 int tt_trace_tmp;                       /* extra var (lasts between blocks) */
371
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 */
375
376
377
378 #ifdef TT_TRACE_NMBCHARS
379 #define TT_TRACE_LEX()          tt_trace_cvtok(tt_trace_lex())
380 /*
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.
384 */
385 #if defined(__STDC__) || defined(__cplusplus)
386 int tt_trace_cvtok(int i)
387 #else
388 int tt_trace_cvtok(i) int i;
389 #endif
390 {
391         int first = 0;
392         int last = TT_TRACE_NMBCHARS - 1;
393         int mid;
394         wchar_t j;
395
396         if(i&0x60000000){/*Must convert to a token. */
397                 if( tt_trace_mbchars[last].character < i ){
398                         return i;/*Giving up*/
399                 }
400                 while ((last>=first)&&(first>=0)) {/*Binary search loop*/
401                         mid = (first+last)/2;
402                         j = tt_trace_mbchars[mid].character;
403                         if( j==i ){/*Found*/ 
404                                 return tt_trace_mbchars[mid].tvalue;
405                         }else if( j<i ){
406                                 first = mid + 1;
407                         }else{
408                                 last = mid -1;
409                         }
410                 }
411                 /*No entry in the table.*/
412                 return i;/* Giving up.*/
413         }else{/* i is already a token. */
414                 return i;
415         }
416 }
417 #else/*!TT_TRACE_NMBCHARS*/
418 #define TT_TRACE_LEX()          tt_trace_lex()
419 #endif/*!TT_TRACE_NMBCHARS*/
420
421 /*
422 ** tt_trace_parse - return 0 if worked, 1 if syntax error not recovered from
423 */
424 #if defined(__STDC__) || defined(__cplusplus)
425 int tt_trace_parse(void)
426 #else
427 int tt_trace_parse()
428 #endif
429 {
430         TT_TRACE_STYPE *tt_trace_pvt;   /* top of value stack for $vars */
431
432 #if defined(__cplusplus) || defined(lint)
433 /*
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.
436 */
437         static int __yaccpar_lint_hack__ = 0;
438         switch (__yaccpar_lint_hack__)
439         {
440                 case 1: goto tt_trace_errlab;
441                 case 2: goto tt_trace_newstate;
442         }
443         tt_trace_pvt = 0;
444 #endif
445
446         /*
447         ** Initialize externals - tt_trace_parse may be called more than once
448         */
449         tt_trace_pv = &tt_trace_v[-1];
450         tt_trace_ps = &tt_trace_s[-1];
451         tt_trace_state = 0;
452         tt_trace_tmp = 0;
453         tt_trace_nerrs = 0;
454         tt_trace_errflag = 0;
455         tt_trace_char = -1;
456
457 #if TT_TRACE_MAXDEPTH <= 0
458         if (tt_trace_maxdepth <= 0)
459         {
460                 if ((tt_trace_maxdepth = TT_TRACE_EXPAND(0)) <= 0)
461                 {
462                         tt_trace_error("yacc initialization error");
463                         TT_TRACE_ABORT;
464                 }
465         }
466 #endif
467
468         {
469                 TT_TRACE_STYPE *tt_trace__pv;   /* top of value stack */
470                 int *tt_trace__ps;              /* top of state stack */
471                 int tt_trace__state;            /* current state */
472                 int  tt_trace__n;               /* internal state number info */
473         goto tt_trace_stack;    /* moved from 6 lines above to here to please C++ */
474
475                 /*
476                 ** get globals into registers.
477                 ** branch to here only if TT_TRACE_BACKUP was called.
478                 */
479         tt_trace_newstate:
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;
484
485                 /*
486                 ** get globals into registers.
487                 ** either we just started, or we just finished a reduction
488                 */
489         tt_trace_stack:
490                 tt_trace__pv = tt_trace_pv;
491                 tt_trace__ps = tt_trace_ps;
492                 tt_trace__state = tt_trace_state;
493
494                 /*
495                 ** top of for (;;) loop while no reductions done
496                 */
497         tt_trace__stack:
498                 /*
499                 ** put a state and value onto the stacks
500                 */
501 #if TT_TRACE_DEBUG
502                 /*
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.
507                 */
508                 if ( tt_trace_debug )
509                 {
510                         int tt_trace__i;
511
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" );
517                         else
518                         {
519                                 for ( tt_trace__i = 0; tt_trace_toks[tt_trace__i].t_val >= 0;
520                                         tt_trace__i++ )
521                                 {
522                                         if ( tt_trace_toks[tt_trace__i].t_val == tt_trace_char )
523                                                 break;
524                                 }
525                                 printf( "%s\n", tt_trace_toks[tt_trace__i].t_name );
526                         }
527                 }
528 #endif /* TT_TRACE_DEBUG */
529                 if ( ++tt_trace__ps >= &tt_trace_s[ tt_trace_maxdepth ] )       /* room on stack? */
530                 {
531                         /*
532                         ** reallocate and recover.  Note that pointers
533                         ** have to be reset, or bad things will happen
534                         */
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);
538                         int tt_trace_newmax;
539 #ifdef TT_TRACE_EXPAND
540                         tt_trace_newmax = TT_TRACE_EXPAND(tt_trace_maxdepth);
541 #else
542                         tt_trace_newmax = 2 * tt_trace_maxdepth;        /* double table size */
543                         if (tt_trace_maxdepth == TT_TRACE_MAXDEPTH)     /* first time growth */
544                         {
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)
548                                 {
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);
551                                 }
552                                 else
553                                         tt_trace_newmax = 0;    /* failed */
554                         }
555                         else                            /* not first time */
556                         {
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 */
561                         }
562 #endif
563                         if (tt_trace_newmax <= tt_trace_maxdepth)       /* tables not expanded */
564                         {
565                                 tt_trace_error( "yacc stack overflow" );
566                                 TT_TRACE_ABORT;
567                         }
568                         tt_trace_maxdepth = tt_trace_newmax;
569
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;
573                 }
574                 *tt_trace__ps = tt_trace__state;
575                 *++tt_trace__pv = tt_trace_val;
576
577                 /*
578                 ** we have a new state - find out what to do
579                 */
580         tt_trace__newstate:
581                 if ( ( tt_trace__n = tt_trace_pact[ tt_trace__state ] ) <= TT_TRACE_FLAG )
582                         goto tt_trace_default;          /* simple state */
583 #if TT_TRACE_DEBUG
584                 /*
585                 ** if debugging, need to mark whether new token grabbed
586                 */
587                 tt_trace_tmp = tt_trace_char < 0;
588 #endif
589                 if ( ( tt_trace_char < 0 ) && ( ( tt_trace_char = TT_TRACE_LEX() ) < 0 ) )
590                         tt_trace_char = 0;              /* reached EOF */
591 #if TT_TRACE_DEBUG
592                 if ( tt_trace_debug && tt_trace_tmp )
593                 {
594                         int tt_trace__i;
595
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" );
601                         else
602                         {
603                                 for ( tt_trace__i = 0; tt_trace_toks[tt_trace__i].t_val >= 0;
604                                         tt_trace__i++ )
605                                 {
606                                         if ( tt_trace_toks[tt_trace__i].t_val == tt_trace_char )
607                                                 break;
608                                 }
609                                 printf( "%s\n", tt_trace_toks[tt_trace__i].t_name );
610                         }
611                 }
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*/
616                 {
617                         tt_trace_char = -1;
618                         tt_trace_val = tt_trace_lval;
619                         tt_trace__state = tt_trace__n;
620                         if ( tt_trace_errflag > 0 )
621                                 tt_trace_errflag--;
622                         goto tt_trace__stack;
623                 }
624
625         tt_trace_default:
626                 if ( ( tt_trace__n = tt_trace_def[ tt_trace__state ] ) == -2 )
627                 {
628 #if TT_TRACE_DEBUG
629                         tt_trace_tmp = tt_trace_char < 0;
630 #endif
631                         if ( ( tt_trace_char < 0 ) && ( ( tt_trace_char = TT_TRACE_LEX() ) < 0 ) )
632                                 tt_trace_char = 0;              /* reached EOF */
633 #if TT_TRACE_DEBUG
634                         if ( tt_trace_debug && tt_trace_tmp )
635                         {
636                                 int tt_trace__i;
637
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" );
643                                 else
644                                 {
645                                         for ( tt_trace__i = 0;
646                                                 tt_trace_toks[tt_trace__i].t_val >= 0;
647                                                 tt_trace__i++ )
648                                         {
649                                                 if ( tt_trace_toks[tt_trace__i].t_val
650                                                         == tt_trace_char )
651                                                 {
652                                                         break;
653                                                 }
654                                         }
655                                         printf( "%s\n", tt_trace_toks[tt_trace__i].t_name );
656                                 }
657                         }
658 #endif /* TT_TRACE_DEBUG */
659                         /*
660                         ** look through exception table
661                         */
662                         {
663                                 int *tt_trace_xi = tt_trace_exca;
664
665                                 while ( ( *tt_trace_xi != -1 ) ||
666                                         ( tt_trace_xi[1] != tt_trace__state ) )
667                                 {
668                                         tt_trace_xi += 2;
669                                 }
670                                 while ( ( *(tt_trace_xi += 2) >= 0 ) &&
671                                         ( *tt_trace_xi != tt_trace_char ) )
672                                         ;
673                                 if ( ( tt_trace__n = tt_trace_xi[1] ) < 0 )
674                                         TT_TRACE_ACCEPT;
675                         }
676                 }
677
678                 /*
679                 ** check for syntax error
680                 */
681                 if ( tt_trace__n == 0 ) /* have an error */
682                 {
683                         /* no worry about speed here! */
684                         switch ( tt_trace_errflag )
685                         {
686                         case 0:         /* new error */
687                                 tt_trace_error( "syntax error" );
688                                 goto skip_init;
689                         tt_trace_errlab:
690                                 /*
691                                 ** get globals into registers.
692                                 ** we have a user generated syntax type error
693                                 */
694                                 tt_trace__pv = tt_trace_pv;
695                                 tt_trace__ps = tt_trace_ps;
696                                 tt_trace__state = tt_trace_state;
697                         skip_init:
698                                 tt_trace_nerrs++;
699                                 /* FALLTHRU */
700                         case 1:
701                         case 2:         /* incompletely recovered error */
702                                         /* try again... */
703                                 tt_trace_errflag = 3;
704                                 /*
705                                 ** find state where "error" is a legal
706                                 ** shift action
707                                 */
708                                 while ( tt_trace__ps >= tt_trace_s )
709                                 {
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)                                    {
713                                                 /*
714                                                 ** simulate shift of "error"
715                                                 */
716                                                 tt_trace__state = tt_trace_act[ tt_trace__n ];
717                                                 goto tt_trace__stack;
718                                         }
719                                         /*
720                                         ** current state has no shift on
721                                         ** "error", pop stack
722                                         */
723 #if TT_TRACE_DEBUG
724 #       define _POP_ "Error recovery pops state %d, uncovers state %d\n"
725                                         if ( tt_trace_debug )
726                                                 printf( _POP_, *tt_trace__ps,
727                                                         tt_trace__ps[-1] );
728 #       undef _POP_
729 #endif
730                                         tt_trace__ps--;
731                                         tt_trace__pv--;
732                                 }
733                                 /*
734                                 ** there is no state on stack with "error" as
735                                 ** a valid shift.  give up.
736                                 */
737                                 TT_TRACE_ABORT;
738                         case 3:         /* no shift yet; eat a token */
739 #if TT_TRACE_DEBUG
740                                 /*
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
745                                 ** tests here.
746                                 */
747                                 if ( tt_trace_debug )
748                                 {
749                                         int tt_trace__i;
750
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" );
756                                         else
757                                         {
758                                                 for ( tt_trace__i = 0;
759                                                         tt_trace_toks[tt_trace__i].t_val >= 0;
760                                                         tt_trace__i++ )
761                                                 {
762                                                         if ( tt_trace_toks[tt_trace__i].t_val
763                                                                 == tt_trace_char )
764                                                         {
765                                                                 break;
766                                                         }
767                                                 }
768                                                 printf( "token %s\n",
769                                                         tt_trace_toks[tt_trace__i].t_name );
770                                         }
771                                 }
772 #endif /* TT_TRACE_DEBUG */
773                                 if ( tt_trace_char == 0 )       /* reached EOF. quit */
774                                         TT_TRACE_ABORT;
775                                 tt_trace_char = -1;
776                                 goto tt_trace__newstate;
777                         }
778                 }/* end if ( tt_trace__n == 0 ) */
779                 /*
780                 ** reduction by production tt_trace__n
781                 ** put stack tops, etc. so things right after switch
782                 */
783 #if TT_TRACE_DEBUG
784                 /*
785                 ** if debugging, print the string that is the user's
786                 ** specification of the reduction which is just about
787                 ** to be done.
788                 */
789                 if ( tt_trace_debug )
790                         printf( "Reduce by (%d) \"%s\"\n",
791                                 tt_trace__n, tt_trace_reds[ tt_trace__n ] );
792 #endif
793                 tt_trace_tmp = tt_trace__n;                     /* value to switch over */
794                 tt_trace_pvt = tt_trace__pv;                    /* $vars top of value stack */
795                 /*
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.
806                 */
807                 {
808                         /* length of production doubled with extra bit */
809                         int tt_trace__len = tt_trace_r2[ tt_trace__n ];
810
811                         if ( !( tt_trace__len & 01 ) )
812                         {
813                                 tt_trace__len >>= 1;
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 )
820                                 {
821                                         tt_trace__state = tt_trace_act[ tt_trace_pgo[ tt_trace__n ] ];
822                                 }
823                                 goto tt_trace__stack;
824                         }
825                         tt_trace__len >>= 1;
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 )
831                         {
832                                 tt_trace__state = tt_trace_act[ tt_trace_pgo[ tt_trace__n ] ];
833                         }
834                 }
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;
839         }
840         /*
841         ** code supplied by user is placed in this switch
842         */
843         switch( tt_trace_tmp )
844         {
845                 
846 case 1:
847 # line 97 "util/tt_trace_gram.y"
848 {
849                         if (parsed)
850                                 ret = 0;
851                         else
852                                 ret = 1;
853                         parsed = 0;
854                         return ret;
855                 } break;
856 case 3:
857 # line 107 "util/tt_trace_gram.y"
858 { parsed = 1; wrapped = 0; } break;
859 case 4:
860 # line 108 "util/tt_trace_gram.y"
861 { parsed = 1; wrapped = 0; } break;
862 case 5:
863 # line 109 "util/tt_trace_gram.y"
864 { parsed = 1; wrapped = 0; } break;
865 case 6:
866 # line 110 "util/tt_trace_gram.y"
867 { parsed = 1; wrapped = 0; } break;
868 case 7:
869 # line 111 "util/tt_trace_gram.y"
870 { parsed = 1; wrapped = 0; } break;
871 case 8:
872 # line 112 "util/tt_trace_gram.y"
873 { parsed = 1; wrapped = 0; } break;
874 case 9:
875 # line 113 "util/tt_trace_gram.y"
876 { parsed = 1; wrapped = 0; } break;
877 case 10:
878 # line 114 "util/tt_trace_gram.y"
879 { parsed = 1; wrapped = 0; } break;
880 case 11:
881 # line 115 "util/tt_trace_gram.y"
882 { parsed = 1; wrapped = 0; } break;
883 case 14:
884 # line 123 "util/tt_trace_gram.y"
885 { _tt_process_follow(tt_trace_pvt[-1].tokenval); } break;
886 case 15:
887 # line 127 "util/tt_trace_gram.y"
888 { _tt_process_sink(tt_trace_pvt[-1].string, O_RDWR | O_CREAT); } break;
889 case 16:
890 # line 129 "util/tt_trace_gram.y"
891 { _tt_process_sink(tt_trace_pvt[-1].string, O_APPEND | O_CREAT); } break;
892 case 17:
893 # line 137 "util/tt_trace_gram.y"
894 { _tt_process_sink(tt_trace_pvt[-1].string, O_RDWR | O_CREAT); } break;
895 case 18:
896 # line 139 "util/tt_trace_gram.y"
897 { _tt_process_sink(tt_trace_pvt[-1].string, O_APPEND | O_CREAT); } break;
898 case 19:
899 # line 143 "util/tt_trace_gram.y"
900 { _tt_clear_functions(); } break;
901 case 20:
902 # line 147 "util/tt_trace_gram.y"
903 { _tt_process_functionlist(tt_trace_pvt[-0].string); } break;
904 case 21:
905 # line 149 "util/tt_trace_gram.y"
906 { _tt_process_functionlist(tt_trace_pvt[-0].string); } break;
907 case 22:
908 # line 153 "util/tt_trace_gram.y"
909 {
910                                         all = (tt_trace_pvt[-1].tokenval == _TT_TRACE_ALL ? 1 : 0);
911                                         _tt_process_functions_allnone(all);
912                                 } break;
913 case 24:
914 # line 161 "util/tt_trace_gram.y"
915 {
916                                         all = (tt_trace_pvt[-1].tokenval == _TT_TRACE_ALL ? 1 : 0);
917                                         _tt_process_attributes(tt_trace_pvt[-1].tokenval);
918                                 } break;
919 case 25:
920 # line 170 "util/tt_trace_gram.y"
921 { _tt_clear_states(); } break;
922 case 26:
923 # line 173 "util/tt_trace_gram.y"
924 {
925                                         /* process_states can't fail here because the
926                                          * grammar ensures that this is the first
927                                          * value on the line
928                                          */
929                                         (void) _tt_process_state(tt_trace_pvt[-0].stateval.state_type,
930                                                              tt_trace_pvt[-0].stateval.state_val);
931                                 } break;
932 case 27:
933 # line 182 "util/tt_trace_gram.y"
934 {
935                                         if (!_tt_process_state(tt_trace_pvt[-0].stateval.state_type,
936                                                           tt_trace_pvt[-0].stateval.state_val)) {
937                                                 _tt_trace_iserr = 2;
938                                                 tt_trace_error("Can't mix none with other state values");
939                                         }
940                                 } break;
941 case 28:
942 # line 190 "util/tt_trace_gram.y"
943 {
944                                         /* process_states can't fail here because the
945                                          * grammar ensures that this is the first
946                                          * value on the line
947                                          */
948
949                                         if (tt_trace_pvt[-0].tokenval == _TT_TRACE_NONE) {
950                                                 _tt_process_state(_TT_TRACE_STATES_NEDD,
951                                                               _TT_TRACE_NONE);
952                                         }
953                                         else {   /* Syntax error */
954                                                 _tt_trace_iserr = 3;
955                                                 tt_trace_error("Bad value for state");
956                                         }
957                                 } break;
958 case 29:
959 # line 206 "util/tt_trace_gram.y"
960 {
961                                         if (tt_trace_pvt[-0].tokenval == _TT_TRACE_NONE) {
962                                                 if (!_tt_process_state(_TT_TRACE_STATES_NEDD,
963                                                                    _TT_TRACE_NONE)) {
964                                                         _tt_trace_iserr = 2;
965                                                         tt_trace_error("Can't mix none with other state values");
966                                                 }
967                                         }
968                                         else {   /* Syntax error */
969                                                 _tt_trace_iserr = 3;
970                                                 tt_trace_error("Bad value for state");
971                                         }
972                                 } break;
973 case 31:
974 # line 227 "util/tt_trace_gram.y"
975 { _tt_create_op_list(tt_trace_pvt[-0].string); } break;
976 case 32:
977 # line 229 "util/tt_trace_gram.y"
978 { _tt_add_op(tt_trace_pvt[-0].string); } break;
979 case 34:
980 # line 235 "util/tt_trace_gram.y"
981 { _tt_create_sp_list(tt_trace_pvt[-0].string); } break;
982 case 35:
983 # line 237 "util/tt_trace_gram.y"
984 { _tt_add_sender_ptype(tt_trace_pvt[-0].string); } break;
985 case 37:
986 # line 243 "util/tt_trace_gram.y"
987 { _tt_create_hp_list(tt_trace_pvt[-0].string); } break;
988 case 38:
989 # line 245 "util/tt_trace_gram.y"
990 { _tt_add_handler_ptype(tt_trace_pvt[-0].string); } break;
991         }
992         goto tt_trace_stack;            /* reset registers in driver code */
993 }
994