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 /* $TOG: OL_DataExpr.C /main/4 1997/12/23 11:38:27 bill $ */
25 __attribute__((unused))
26 static const char ol_datasccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
28 #define ol_dataBYACC 1
29 #line 2 "OL_DataExpr.y"
32 #include "Expression.h"
33 #include "ContentType.h"
35 extern int ol_datalex();
36 extern void ol_dataerror( char *str );
38 extern ContentType *CurrentContentPtr;
40 #line 14 "OL_DataExpr.y"
54 #define ol_dataERRCODE 256
55 short ol_datalhs[] = { -1,
56 0, 2, 2, 1, 1, 1, 1, 1, 1, 1,
58 short ol_datalen[] = { 2,
59 1, 1, 3, 1, 1, 4, 4, 4, 1, 1,
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,
66 short ol_datadgoto[] = { 8,
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,
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,
79 short ol_datagindex[] = { 0,
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,
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,
97 #define ol_dataFINAL 8
99 #define ol_dataDEBUG 0
101 #define ol_dataMAXTOKEN 263
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",
113 char *ol_datarule[] = {
115 "ValList : ExprList",
117 "ExprList : Expr ',' ExprList",
120 "Expr : Concat '(' ExprList ')'",
121 "Expr : Attr '(' Id ')'",
122 "Expr : FirstOf '(' ExprList ')'",
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
134 #ifdef ol_dataMAXDEPTH
135 #define ol_dataSTACKSIZE ol_dataMAXDEPTH
137 #define ol_dataSTACKSIZE 500
138 #define ol_dataMAXDEPTH 500
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"
160 #define ol_dataABORT goto ol_dataabort
161 #define ol_dataACCEPT goto ol_dataaccept
162 #define ol_dataERROR goto ol_dataerrlab
165 extern char *getenv(const char *);
171 register int ol_datam, ol_datan, ol_datastate;
173 register char *ol_datas;
175 if ((ol_datas = getenv("ol_dataDEBUG")))
177 ol_datan = *ol_datas;
178 if (ol_datan >= '0' && ol_datan <= '9')
179 ol_datadebug = ol_datan - '0';
187 ol_datassp = ol_datass;
188 ol_datavsp = ol_datavs;
189 *ol_datassp = ol_datastate = 0;
192 if ((ol_datan = ol_datadefred[ol_datastate])) goto ol_datareduce;
195 if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 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);
207 if ((ol_datan = ol_datasindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
208 ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
212 printf("ol_datadebug: state %d, shifting to state %d\n",
213 ol_datastate, ol_datatable[ol_datan]);
215 if (ol_datassp >= ol_datass + ol_datastacksize - 1)
217 goto ol_dataoverflow;
219 *++ol_datassp = ol_datastate = ol_datatable[ol_datan];
220 *++ol_datavsp = ol_datalval;
222 if (ol_dataerrflag > 0) --ol_dataerrflag;
225 if ((ol_datan = ol_datarindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
226 ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
228 ol_datan = ol_datatable[ol_datan];
231 if (ol_dataerrflag) goto ol_datainrecovery;
235 goto ol_datanewerror;
239 ol_dataerror((char*)"syntax error");
249 if (ol_dataerrflag < 3)
254 if ((ol_datan = ol_datasindex[*ol_datassp]) && (ol_datan += ol_dataERRCODE) >= 0 &&
255 ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_dataERRCODE)
259 printf("ol_datadebug: state %d, error recovery shifting\
260 to state %d\n", *ol_datassp, ol_datatable[ol_datan]);
262 if (ol_datassp >= ol_datass + ol_datastacksize - 1)
264 goto ol_dataoverflow;
266 *++ol_datassp = ol_datastate = ol_datatable[ol_datan];
267 *++ol_datavsp = ol_datalval;
274 printf("ol_datadebug: error recovery discarding state %d\n",
277 if (ol_datassp <= ol_datass) goto ol_dataabort;
285 if (ol_datachar == 0) goto ol_dataabort;
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);
302 printf("ol_datadebug: state %d, reducing by rule %d (%s)\n",
303 ol_datastate, ol_datan, ol_datarule[ol_datan]);
305 ol_datam = ol_datalen[ol_datan];
306 ol_dataval = ol_datavsp[1-ol_datam];
310 #line 36 "OL_DataExpr.y"
312 CurrentContentPtr->init(ol_datavsp[0].eptr);
316 #line 42 "OL_DataExpr.y"
318 ol_dataval.eptr = ol_datavsp[0].eptr;
322 #line 46 "OL_DataExpr.y"
324 ol_datavsp[-2].eptr->next = ol_datavsp[0].eptr;
325 ol_dataval.eptr = ol_datavsp[-2].eptr;
329 #line 53 "OL_DataExpr.y"
331 OL_Expression *expr = new OL_Expression( GENERIC_ID, ol_datavsp[0].name);
332 ol_dataval.eptr = expr;
336 #line 59 "OL_DataExpr.y"
338 OL_Expression *expr = new OL_Expression( CONTENT );
339 ol_dataval.eptr = expr;
343 #line 65 "OL_DataExpr.y"
345 ExprList *elist = new ExprList( ol_datavsp[-1].eptr );
346 OL_Expression *expr = new OL_Expression( CONCAT, -1, elist);
347 ol_dataval.eptr = expr;
351 #line 71 "OL_DataExpr.y"
353 OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[-1].name);
354 ol_dataval.eptr = expr;
358 #line 76 "OL_DataExpr.y"
360 ExprList *elist = new ExprList ( ol_datavsp[-1].eptr );
361 OL_Expression *expr = new OL_Expression( FIRSTOF, -1, elist );
362 ol_dataval.eptr = expr;
366 #line 83 "OL_DataExpr.y"
368 OL_Expression *expr = new OL_Expression( LITERAL, -1, ol_datavsp[0].string );
369 ol_dataval.eptr = expr;
373 #line 89 "OL_DataExpr.y"
375 OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[0].name );
376 ol_dataval.eptr = expr;
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)
389 printf("ol_datadebug: after reduction, shifting from state 0 to\
390 state %d\n", ol_dataFINAL);
392 ol_datastate = ol_dataFINAL;
393 *++ol_datassp = ol_dataFINAL;
394 *++ol_datavsp = ol_dataval;
397 if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 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);
409 if (ol_datachar == 0) goto ol_dataaccept;
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];
416 ol_datastate = ol_datadgoto[ol_datam];
419 printf("ol_datadebug: after reduction, shifting from state %d \
420 to state %d\n", *ol_datassp, ol_datastate);
422 if (ol_datassp >= ol_datass + ol_datastacksize - 1)
424 goto ol_dataoverflow;
426 *++ol_datassp = ol_datastate;
427 *++ol_datavsp = ol_dataval;
430 ol_dataerror((char*)"yacc stack overflow");