Fix warnings on FreeBSD
[oweals/cde.git] / cde / programs / dtinfo / dtinfogen / infolib / etc / OL_DataExpr.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 /* $TOG: OL_DataExpr.C /main/4 1997/12/23 11:38:27 bill $ */
24 #ifndef lint
25 __attribute__((unused))
26 static const char ol_datasccsid[] = "@(#)yaccpar        1.8 (Berkeley) 01/20/90";
27 #endif
28 #define ol_dataBYACC 1
29 #line 2 "OL_DataExpr.y"
30 #include <stdio.h>
31 #include "ExprList.h"
32 #include "Expression.h"
33 #include "ContentType.h"
34
35 extern int ol_datalex();
36 extern void ol_dataerror( char *str );
37
38 extern ContentType *CurrentContentPtr;
39
40 #line 14 "OL_DataExpr.y"
41 typedef union {
42   int        name;
43   char       *string;
44   OL_Expression *eptr;
45 } ol_dataSTYPE;
46 #line 23 "y.tab.c"
47 #define Reference 257
48 #define Id 258
49 #define Literal 259
50 #define Content 260
51 #define Concat 261
52 #define Attr 262
53 #define FirstOf 263
54 #define ol_dataERRCODE 256
55 short ol_datalhs[] = {                                        -1,
56     0,    2,    2,    1,    1,    1,    1,    1,    1,    1,
57 };
58 short ol_datalen[] = {                                         2,
59     1,    1,    3,    1,    1,    4,    4,    4,    1,    1,
60 };
61 short ol_datadefred[] = {                                      0,
62    10,    4,    9,    5,    0,    0,    0,    0,    0,    1,
63     0,    0,    0,    0,    0,    0,    0,    3,    6,    7,
64     8,
65 };
66 short ol_datadgoto[] = {                                       8,
67     9,   10,
68 };
69 short ol_datasindex[] = {                                   -255,
70     0,    0,    0,    0,  -40,  -30,  -27,    0,  -29,    0,
71  -255, -244, -255, -255,  -25,  -24,  -23,    0,    0,    0,
72     0,
73 };
74 short ol_datarindex[] = {                                      0,
75     0,    0,    0,    0,    0,    0,    0,    0,    1,    0,
76     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
77     0,
78 };
79 short ol_datagindex[] = {                                      0,
80     0,   -2,
81 };
82 #define ol_dataTABLESIZE 42
83 short ol_datatable[] = {                                      11,
84     2,    1,    2,    3,    4,    5,    6,    7,   15,   12,
85    17,   18,   13,   16,   14,   19,   20,   21,    0,    0,
86     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
87     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
88     0,    2,
89 };
90 short ol_datacheck[] = {                                      40,
91     0,  257,  258,  259,  260,  261,  262,  263,   11,   40,
92    13,   14,   40,  258,   44,   41,   41,   41,   -1,   -1,
93    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
94    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
95    -1,   41,
96 };
97 #define ol_dataFINAL 8
98 #ifndef ol_dataDEBUG
99 #define ol_dataDEBUG 0
100 #endif
101 #define ol_dataMAXTOKEN 263
102 #if ol_dataDEBUG
103 char *ol_dataname[] = {
104 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
105 0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
106 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
107 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
108 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
109 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
110 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"Reference","Id",
111 "Literal","Content","Concat","Attr","FirstOf",
112 };
113 char *ol_datarule[] = {
114 "$accept : ValList",
115 "ValList : ExprList",
116 "ExprList : Expr",
117 "ExprList : Expr ',' ExprList",
118 "Expr : Id",
119 "Expr : Content",
120 "Expr : Concat '(' ExprList ')'",
121 "Expr : Attr '(' Id ')'",
122 "Expr : FirstOf '(' ExprList ')'",
123 "Expr : Literal",
124 "Expr : Reference",
125 };
126 #endif
127 #define ol_dataclearin (ol_datachar=(-1))
128 #define ol_dataerrok (ol_dataerrflag=0)
129 #ifdef ol_dataSTACKSIZE
130 #ifndef ol_dataMAXDEPTH
131 #define ol_dataMAXDEPTH ol_dataSTACKSIZE
132 #endif
133 #else
134 #ifdef ol_dataMAXDEPTH
135 #define ol_dataSTACKSIZE ol_dataMAXDEPTH
136 #else
137 #define ol_dataSTACKSIZE 500
138 #define ol_dataMAXDEPTH 500
139 #endif
140 #endif
141 int ol_datadebug;
142 int ol_datanerrs;
143 int ol_dataerrflag;
144 int ol_datachar;
145 short *ol_datassp;
146 ol_dataSTYPE *ol_datavsp;
147 ol_dataSTYPE ol_dataval;
148 ol_dataSTYPE ol_datalval;
149 short ol_datass[ol_dataSTACKSIZE];
150 ol_dataSTYPE ol_datavs[ol_dataSTACKSIZE];
151 #define ol_datastacksize ol_dataSTACKSIZE
152 #line 97 "OL_DataExpr.y"
153         
154
155
156   
157
158
159 #line 136 "y.tab.c"
160 #define ol_dataABORT goto ol_dataabort
161 #define ol_dataACCEPT goto ol_dataaccept
162 #define ol_dataERROR goto ol_dataerrlab
163 #if ol_dataDEBUG
164 #ifndef __cplusplus
165 extern char *getenv(const char *);
166 #endif
167 #endif
168 int
169 ol_dataparse()
170 {
171     register int ol_datam, ol_datan, ol_datastate;
172 #if ol_dataDEBUG
173     register char *ol_datas;
174
175     if ((ol_datas = getenv("ol_dataDEBUG")))
176     {
177         ol_datan = *ol_datas;
178         if (ol_datan >= '0' && ol_datan <= '9')
179             ol_datadebug = ol_datan - '0';
180     }
181 #endif
182
183     ol_datanerrs = 0;
184     ol_dataerrflag = 0;
185     ol_datachar = (-1);
186
187     ol_datassp = ol_datass;
188     ol_datavsp = ol_datavs;
189     *ol_datassp = ol_datastate = 0;
190
191 ol_dataloop:
192     if ((ol_datan = ol_datadefred[ol_datastate])) goto ol_datareduce;
193     if (ol_datachar < 0)
194     {
195         if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 0;
196 #if ol_dataDEBUG
197         if (ol_datadebug)
198         {
199             ol_datas = 0;
200             if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
201             if (!ol_datas) ol_datas = "illegal-symbol";
202             printf("ol_datadebug: state %d, reading %d (%s)\n", ol_datastate,
203                     ol_datachar, ol_datas);
204         }
205 #endif
206     }
207     if ((ol_datan = ol_datasindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
208             ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
209     {
210 #if ol_dataDEBUG
211         if (ol_datadebug)
212             printf("ol_datadebug: state %d, shifting to state %d\n",
213                     ol_datastate, ol_datatable[ol_datan]);
214 #endif
215         if (ol_datassp >= ol_datass + ol_datastacksize - 1)
216         {
217             goto ol_dataoverflow;
218         }
219         *++ol_datassp = ol_datastate = ol_datatable[ol_datan];
220         *++ol_datavsp = ol_datalval;
221         ol_datachar = (-1);
222         if (ol_dataerrflag > 0)  --ol_dataerrflag;
223         goto ol_dataloop;
224     }
225     if ((ol_datan = ol_datarindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
226             ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
227     {
228         ol_datan = ol_datatable[ol_datan];
229         goto ol_datareduce;
230     }
231     if (ol_dataerrflag) goto ol_datainrecovery;
232 // Disable for now
233 #if 0
234 #ifdef lint
235     goto ol_datanewerror;
236 #endif
237 ol_datanewerror:
238 #endif /* 0 */
239     ol_dataerror((char*)"syntax error");
240 // Disable for now
241 #if 0
242 #ifdef lint
243     goto ol_dataerrlab;
244 #endif
245 ol_dataerrlab:
246 #endif /* 0 */
247     ++ol_datanerrs;
248 ol_datainrecovery:
249     if (ol_dataerrflag < 3)
250     {
251         ol_dataerrflag = 3;
252         for (;;)
253         {
254             if ((ol_datan = ol_datasindex[*ol_datassp]) && (ol_datan += ol_dataERRCODE) >= 0 &&
255                     ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_dataERRCODE)
256             {
257 #if ol_dataDEBUG
258                 if (ol_datadebug)
259                     printf("ol_datadebug: state %d, error recovery shifting\
260  to state %d\n", *ol_datassp, ol_datatable[ol_datan]);
261 #endif
262                 if (ol_datassp >= ol_datass + ol_datastacksize - 1)
263                 {
264                     goto ol_dataoverflow;
265                 }
266                 *++ol_datassp = ol_datastate = ol_datatable[ol_datan];
267                 *++ol_datavsp = ol_datalval;
268                 goto ol_dataloop;
269             }
270             else
271             {
272 #if ol_dataDEBUG
273                 if (ol_datadebug)
274                     printf("ol_datadebug: error recovery discarding state %d\n",
275                             *ol_datassp);
276 #endif
277                 if (ol_datassp <= ol_datass) goto ol_dataabort;
278                 --ol_datassp;
279                 --ol_datavsp;
280             }
281         }
282     }
283     else
284     {
285         if (ol_datachar == 0) goto ol_dataabort;
286 #if ol_dataDEBUG
287         if (ol_datadebug)
288         {
289             ol_datas = 0;
290             if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
291             if (!ol_datas) ol_datas = "illegal-symbol";
292             printf("ol_datadebug: state %d, error recovery discards token %d (%s)\n",
293                     ol_datastate, ol_datachar, ol_datas);
294         }
295 #endif
296         ol_datachar = (-1);
297         goto ol_dataloop;
298     }
299 ol_datareduce:
300 #if ol_dataDEBUG
301     if (ol_datadebug)
302         printf("ol_datadebug: state %d, reducing by rule %d (%s)\n",
303                 ol_datastate, ol_datan, ol_datarule[ol_datan]);
304 #endif
305     ol_datam = ol_datalen[ol_datan];
306     ol_dataval = ol_datavsp[1-ol_datam];
307     switch (ol_datan)
308     {
309 case 1:
310 #line 36 "OL_DataExpr.y"
311 {
312                 CurrentContentPtr->init(ol_datavsp[0].eptr);
313               }
314 break;
315 case 2:
316 #line 42 "OL_DataExpr.y"
317 {
318                 ol_dataval.eptr = ol_datavsp[0].eptr;
319               }
320 break;
321 case 3:
322 #line 46 "OL_DataExpr.y"
323 {
324                 ol_datavsp[-2].eptr->next = ol_datavsp[0].eptr;
325                 ol_dataval.eptr = ol_datavsp[-2].eptr;
326               }
327 break;
328 case 4:
329 #line 53 "OL_DataExpr.y"
330 {
331            OL_Expression *expr = new OL_Expression( GENERIC_ID, ol_datavsp[0].name);
332            ol_dataval.eptr = expr;
333          }
334 break;
335 case 5:
336 #line 59 "OL_DataExpr.y"
337 {
338            OL_Expression *expr = new OL_Expression( CONTENT );
339            ol_dataval.eptr = expr;
340          }
341 break;
342 case 6:
343 #line 65 "OL_DataExpr.y"
344 {
345            ExprList   *elist = new ExprList( ol_datavsp[-1].eptr );
346            OL_Expression *expr = new OL_Expression( CONCAT, -1, elist);
347            ol_dataval.eptr = expr;
348          }
349 break;
350 case 7:
351 #line 71 "OL_DataExpr.y"
352 {
353            OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[-1].name);
354            ol_dataval.eptr = expr;
355          }
356 break;
357 case 8:
358 #line 76 "OL_DataExpr.y"
359 {
360            ExprList *elist = new ExprList ( ol_datavsp[-1].eptr );
361            OL_Expression *expr = new OL_Expression( FIRSTOF, -1, elist );
362            ol_dataval.eptr = expr;
363          }
364 break;
365 case 9:
366 #line 83 "OL_DataExpr.y"
367 {
368            OL_Expression *expr = new OL_Expression( LITERAL, -1, ol_datavsp[0].string );
369            ol_dataval.eptr = expr;
370          }
371 break;
372 case 10:
373 #line 89 "OL_DataExpr.y"
374 {
375            OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[0].name );
376            ol_dataval.eptr = expr;
377          }
378 break;
379 #line 350 "y.tab.c"
380     }
381     ol_datassp -= ol_datam;
382     ol_datastate = *ol_datassp;
383     ol_datavsp -= ol_datam;
384     ol_datam = ol_datalhs[ol_datan];
385     if (ol_datastate == 0 && ol_datam == 0)
386     {
387 #if ol_dataDEBUG
388         if (ol_datadebug)
389             printf("ol_datadebug: after reduction, shifting from state 0 to\
390  state %d\n", ol_dataFINAL);
391 #endif
392         ol_datastate = ol_dataFINAL;
393         *++ol_datassp = ol_dataFINAL;
394         *++ol_datavsp = ol_dataval;
395         if (ol_datachar < 0)
396         {
397             if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 0;
398 #if ol_dataDEBUG
399             if (ol_datadebug)
400             {
401                 ol_datas = 0;
402                 if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
403                 if (!ol_datas) ol_datas = "illegal-symbol";
404                 printf("ol_datadebug: state %d, reading %d (%s)\n",
405                         ol_dataFINAL, ol_datachar, ol_datas);
406             }
407 #endif
408         }
409         if (ol_datachar == 0) goto ol_dataaccept;
410         goto ol_dataloop;
411     }
412     if ((ol_datan = ol_datagindex[ol_datam]) && (ol_datan += ol_datastate) >= 0 &&
413             ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datastate)
414         ol_datastate = ol_datatable[ol_datan];
415     else
416         ol_datastate = ol_datadgoto[ol_datam];
417 #if ol_dataDEBUG
418     if (ol_datadebug)
419         printf("ol_datadebug: after reduction, shifting from state %d \
420 to state %d\n", *ol_datassp, ol_datastate);
421 #endif
422     if (ol_datassp >= ol_datass + ol_datastacksize - 1)
423     {
424         goto ol_dataoverflow;
425     }
426     *++ol_datassp = ol_datastate;
427     *++ol_datavsp = ol_dataval;
428     goto ol_dataloop;
429 ol_dataoverflow:
430     ol_dataerror((char*)"yacc stack overflow");
431 ol_dataabort:
432     return (1);
433 ol_dataaccept:
434     return (0);
435 }