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 static const char ol_datasccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
27 #define ol_dataBYACC 1
28 #line 2 "OL_DataExpr.y"
31 #include "Expression.h"
32 #include "ContentType.h"
34 extern int ol_datalex();
35 extern void ol_dataerror( char *str );
37 extern ContentType *CurrentContentPtr;
39 #line 14 "OL_DataExpr.y"
53 #define ol_dataERRCODE 256
54 short ol_datalhs[] = { -1,
55 0, 2, 2, 1, 1, 1, 1, 1, 1, 1,
57 short ol_datalen[] = { 2,
58 1, 1, 3, 1, 1, 4, 4, 4, 1, 1,
60 short ol_datadefred[] = { 0,
61 10, 4, 9, 5, 0, 0, 0, 0, 0, 1,
62 0, 0, 0, 0, 0, 0, 0, 3, 6, 7,
65 short ol_datadgoto[] = { 8,
68 short ol_datasindex[] = { -255,
69 0, 0, 0, 0, -40, -30, -27, 0, -29, 0,
70 -255, -244, -255, -255, -25, -24, -23, 0, 0, 0,
73 short ol_datarindex[] = { 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
75 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
78 short ol_datagindex[] = { 0,
81 #define ol_dataTABLESIZE 42
82 short ol_datatable[] = { 11,
83 2, 1, 2, 3, 4, 5, 6, 7, 15, 12,
84 17, 18, 13, 16, 14, 19, 20, 21, 0, 0,
85 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
86 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
89 short ol_datacheck[] = { 40,
90 0, 257, 258, 259, 260, 261, 262, 263, 11, 40,
91 13, 14, 40, 258, 44, 41, 41, 41, -1, -1,
92 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
93 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
96 #define ol_dataFINAL 8
98 #define ol_dataDEBUG 0
100 #define ol_dataMAXTOKEN 263
102 char *ol_dataname[] = {
103 "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,
104 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,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,"Reference","Id",
110 "Literal","Content","Concat","Attr","FirstOf",
112 char *ol_datarule[] = {
114 "ValList : ExprList",
116 "ExprList : Expr ',' ExprList",
119 "Expr : Concat '(' ExprList ')'",
120 "Expr : Attr '(' Id ')'",
121 "Expr : FirstOf '(' ExprList ')'",
126 #define ol_dataclearin (ol_datachar=(-1))
127 #define ol_dataerrok (ol_dataerrflag=0)
128 #ifdef ol_dataSTACKSIZE
129 #ifndef ol_dataMAXDEPTH
130 #define ol_dataMAXDEPTH ol_dataSTACKSIZE
133 #ifdef ol_dataMAXDEPTH
134 #define ol_dataSTACKSIZE ol_dataMAXDEPTH
136 #define ol_dataSTACKSIZE 500
137 #define ol_dataMAXDEPTH 500
145 ol_dataSTYPE *ol_datavsp;
146 ol_dataSTYPE ol_dataval;
147 ol_dataSTYPE ol_datalval;
148 short ol_datass[ol_dataSTACKSIZE];
149 ol_dataSTYPE ol_datavs[ol_dataSTACKSIZE];
150 #define ol_datastacksize ol_dataSTACKSIZE
151 #line 97 "OL_DataExpr.y"
159 #define ol_dataABORT goto ol_dataabort
160 #define ol_dataACCEPT goto ol_dataaccept
161 #define ol_dataERROR goto ol_dataerrlab
164 extern char *getenv(const char *);
170 register int ol_datam, ol_datan, ol_datastate;
172 register char *ol_datas;
174 if ((ol_datas = getenv("ol_dataDEBUG")))
176 ol_datan = *ol_datas;
177 if (ol_datan >= '0' && ol_datan <= '9')
178 ol_datadebug = ol_datan - '0';
186 ol_datassp = ol_datass;
187 ol_datavsp = ol_datavs;
188 *ol_datassp = ol_datastate = 0;
191 if ((ol_datan = ol_datadefred[ol_datastate])) goto ol_datareduce;
194 if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 0;
199 if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
200 if (!ol_datas) ol_datas = "illegal-symbol";
201 printf("ol_datadebug: state %d, reading %d (%s)\n", ol_datastate,
202 ol_datachar, ol_datas);
206 if ((ol_datan = ol_datasindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
207 ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
211 printf("ol_datadebug: state %d, shifting to state %d\n",
212 ol_datastate, ol_datatable[ol_datan]);
214 if (ol_datassp >= ol_datass + ol_datastacksize - 1)
216 goto ol_dataoverflow;
218 *++ol_datassp = ol_datastate = ol_datatable[ol_datan];
219 *++ol_datavsp = ol_datalval;
221 if (ol_dataerrflag > 0) --ol_dataerrflag;
224 if ((ol_datan = ol_datarindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
225 ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
227 ol_datan = ol_datatable[ol_datan];
230 if (ol_dataerrflag) goto ol_datainrecovery;
234 goto ol_datanewerror;
238 ol_dataerror((char*)"syntax error");
248 if (ol_dataerrflag < 3)
253 if ((ol_datan = ol_datasindex[*ol_datassp]) && (ol_datan += ol_dataERRCODE) >= 0 &&
254 ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_dataERRCODE)
258 printf("ol_datadebug: state %d, error recovery shifting\
259 to state %d\n", *ol_datassp, ol_datatable[ol_datan]);
261 if (ol_datassp >= ol_datass + ol_datastacksize - 1)
263 goto ol_dataoverflow;
265 *++ol_datassp = ol_datastate = ol_datatable[ol_datan];
266 *++ol_datavsp = ol_datalval;
273 printf("ol_datadebug: error recovery discarding state %d\n",
276 if (ol_datassp <= ol_datass) goto ol_dataabort;
284 if (ol_datachar == 0) goto ol_dataabort;
289 if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
290 if (!ol_datas) ol_datas = "illegal-symbol";
291 printf("ol_datadebug: state %d, error recovery discards token %d (%s)\n",
292 ol_datastate, ol_datachar, ol_datas);
301 printf("ol_datadebug: state %d, reducing by rule %d (%s)\n",
302 ol_datastate, ol_datan, ol_datarule[ol_datan]);
304 ol_datam = ol_datalen[ol_datan];
305 ol_dataval = ol_datavsp[1-ol_datam];
309 #line 36 "OL_DataExpr.y"
311 CurrentContentPtr->init(ol_datavsp[0].eptr);
315 #line 42 "OL_DataExpr.y"
317 ol_dataval.eptr = ol_datavsp[0].eptr;
321 #line 46 "OL_DataExpr.y"
323 ol_datavsp[-2].eptr->next = ol_datavsp[0].eptr;
324 ol_dataval.eptr = ol_datavsp[-2].eptr;
328 #line 53 "OL_DataExpr.y"
330 OL_Expression *expr = new OL_Expression( GENERIC_ID, ol_datavsp[0].name);
331 ol_dataval.eptr = expr;
335 #line 59 "OL_DataExpr.y"
337 OL_Expression *expr = new OL_Expression( CONTENT );
338 ol_dataval.eptr = expr;
342 #line 65 "OL_DataExpr.y"
344 ExprList *elist = new ExprList( ol_datavsp[-1].eptr );
345 OL_Expression *expr = new OL_Expression( CONCAT, -1, elist);
346 ol_dataval.eptr = expr;
350 #line 71 "OL_DataExpr.y"
352 OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[-1].name);
353 ol_dataval.eptr = expr;
357 #line 76 "OL_DataExpr.y"
359 ExprList *elist = new ExprList ( ol_datavsp[-1].eptr );
360 OL_Expression *expr = new OL_Expression( FIRSTOF, -1, elist );
361 ol_dataval.eptr = expr;
365 #line 83 "OL_DataExpr.y"
367 OL_Expression *expr = new OL_Expression( LITERAL, -1, ol_datavsp[0].string );
368 ol_dataval.eptr = expr;
372 #line 89 "OL_DataExpr.y"
374 OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[0].name );
375 ol_dataval.eptr = expr;
380 ol_datassp -= ol_datam;
381 ol_datastate = *ol_datassp;
382 ol_datavsp -= ol_datam;
383 ol_datam = ol_datalhs[ol_datan];
384 if (ol_datastate == 0 && ol_datam == 0)
388 printf("ol_datadebug: after reduction, shifting from state 0 to\
389 state %d\n", ol_dataFINAL);
391 ol_datastate = ol_dataFINAL;
392 *++ol_datassp = ol_dataFINAL;
393 *++ol_datavsp = ol_dataval;
396 if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 0;
401 if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
402 if (!ol_datas) ol_datas = "illegal-symbol";
403 printf("ol_datadebug: state %d, reading %d (%s)\n",
404 ol_dataFINAL, ol_datachar, ol_datas);
408 if (ol_datachar == 0) goto ol_dataaccept;
411 if ((ol_datan = ol_datagindex[ol_datam]) && (ol_datan += ol_datastate) >= 0 &&
412 ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datastate)
413 ol_datastate = ol_datatable[ol_datan];
415 ol_datastate = ol_datadgoto[ol_datam];
418 printf("ol_datadebug: after reduction, shifting from state %d \
419 to state %d\n", *ol_datassp, ol_datastate);
421 if (ol_datassp >= ol_datass + ol_datastacksize - 1)
423 goto ol_dataoverflow;
425 *++ol_datassp = ol_datastate;
426 *++ol_datavsp = ol_dataval;
429 ol_dataerror((char*)"yacc stack overflow");