merge the formfield patch from ooo-build
[ooovba.git] / hwpfilter / source / grammar.cpp
blob6a203bd239d0a05378319647e0f7a44eaa800b77
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: grammar.cpp,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 /* A Bison parser, made from grammar.y
33 by GNU Bison version 1.28 */
35 #define YYBISON 1 /* Identify Bison output. */
37 #ifndef YYDEBUG
38 #define YYDEBUG 0
39 #endif
40 #ifndef YYMAXDEPTH
41 #define YYMAXDEPTH 0
42 #endif
44 #define ACCENT 257
45 #define SMALL_GREEK 258
46 #define CAPITAL_GREEK 259
47 #define BINARY_OPERATOR 260
48 #define RELATION_OPERATOR 261
49 #define ARROW 262
50 #define GENERAL_IDEN 263
51 #define GENERAL_OPER 264
52 #define BIG_SYMBOL 265
53 #define FUNCTION 266
54 #define ROOT 267
55 #define FRACTION 268
56 #define SUBSUP 269
57 #define EQOVER 270
58 #define DELIMETER 271
59 #define LARGE_DELIM 272
60 #define DECORATION 273
61 #define SPACE_SYMBOL 274
62 #define CHARACTER 275
63 #define STRING 276
64 #define OPERATOR 277
65 #define EQBEGIN 278
66 #define EQEND 279
67 #define EQLEFT 280
68 #define EQRIGHT 281
69 #define NEWLINE 282
70 #define LEFT_DELIM 283
71 #define RIGHT_DELIM 284
72 #define DIGIT 285
74 #line 1 "grammar.y"
76 #include <stdlib.h>
77 #include <string.h>
79 #include "nodes.h"
81 LinkedList<Node> nodelist;
83 Node *mainParse(const char *_code);
84 void yyerror(const char *);
85 int yylex();
86 void initFlex( const char *s );
87 void viewResult(Node *res);
89 Node *top=0L;
91 int Node::count = 0;
93 #define allocValue(x,y) \
94 x = (char *)malloc( strlen(y) +1 ); \
95 strcpy(x,y)
97 #define allocChar(x,y) \
98 x = (char *)malloc(2); \
99 sprintf(x,"%c",y)
100 #ifdef PARSE_DEBUG
101 #define debug printf
102 #else
103 int debug(const char *format, ...);
104 #endif
107 #line 35 "grammar.y"
108 typedef union {
109 char *dval;
110 char *str;
111 Node *ptr;
112 } YYSTYPE;
113 #include <stdio.h>
115 #ifndef __cplusplus
116 #ifndef __STDC__
117 #define const
118 #endif
119 #endif
123 #define YYFINAL 102
124 #define YYFLAG -32768
125 #define YYNTBASE 43
127 #define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66)
129 static const char yytranslate[] = { 0,
130 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
131 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
132 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133 2, 2, 2, 2, 2, 2, 2, 2, 2, 33,
134 37, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135 2, 2, 2, 2, 2, 2, 2, 2, 2, 36,
136 2, 40, 2, 2, 2, 2, 2, 2, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
139 34, 2, 38, 42, 41, 2, 2, 2, 2, 2,
140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
142 2, 2, 35, 32, 39, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
144 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
147 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
149 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
150 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
155 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
156 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
157 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
158 27, 28, 29, 30, 31
161 #if YYDEBUG != 0
162 static const short yyprhs[] = { 0,
163 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
164 20, 22, 24, 26, 28, 30, 32, 34, 36, 39,
165 42, 45, 48, 51, 54, 58, 60, 63, 66, 69,
166 72, 75, 79, 81, 85, 89, 92, 96, 99, 103,
167 106, 110, 114, 120, 124, 130, 132, 135, 137, 140,
168 143, 147, 150, 154, 157, 159, 161, 165, 167, 169,
169 172, 174, 176, 178, 180, 182, 184, 186, 188, 190,
170 192, 194
173 static const short yyrhs[] = { 4,
174 0, 9, 0, 10, 0, 5, 0, 11, 0, 12,
175 0, 20, 0, 21, 0, 7, 0, 6, 0, 23,
176 0, 17, 0, 18, 0, 8, 0, 32, 0, 31,
177 0, 22, 0, 43, 0, 44, 43, 0, 26, 33,
178 0, 26, 34, 0, 26, 35, 0, 26, 36, 0,
179 26, 32, 0, 26, 32, 32, 0, 29, 0, 27,
180 37, 0, 27, 38, 0, 27, 39, 0, 27, 40,
181 0, 27, 32, 0, 27, 32, 32, 0, 30, 0,
182 45, 64, 46, 0, 33, 64, 37, 0, 33, 37,
183 0, 35, 64, 39, 0, 35, 39, 0, 34, 64,
184 38, 0, 34, 38, 0, 65, 41, 65, 0, 65,
185 42, 65, 0, 65, 41, 49, 42, 49, 0, 14,
186 49, 49, 0, 35, 64, 16, 64, 39, 0, 3,
187 0, 54, 49, 0, 19, 0, 56, 49, 0, 13,
188 49, 0, 13, 50, 49, 0, 24, 49, 0, 24,
189 49, 49, 0, 25, 49, 0, 62, 0, 63, 0,
190 62, 28, 63, 0, 64, 0, 65, 0, 64, 65,
191 0, 49, 0, 48, 0, 47, 0, 51, 0, 52,
192 0, 53, 0, 57, 0, 58, 0, 55, 0, 44,
193 0, 59, 0, 60, 0
196 #endif
198 #if YYDEBUG != 0
199 static const short yyrline[] = { 0,
200 59, 61, 62, 63, 64, 65, 66, 67, 68, 69,
201 70, 71, 72, 73, 74, 75, 76, 79, 81, 84,
202 86, 87, 88, 89, 90, 91, 94, 96, 97, 98,
203 99, 100, 101, 104, 108, 110, 113, 115, 118, 120,
204 123, 125, 126, 129, 133, 138, 142, 145, 149, 153,
205 155, 158, 160, 163, 168, 172, 174, 177, 181, 183,
206 186, 188, 189, 190, 191, 192, 193, 194, 195, 196,
207 197, 198
209 #endif
212 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
214 static const char * const yytname[] = { "$","error","$undefined.","ACCENT",
215 "SMALL_GREEK","CAPITAL_GREEK","BINARY_OPERATOR","RELATION_OPERATOR","ARROW",
216 "GENERAL_IDEN","GENERAL_OPER","BIG_SYMBOL","FUNCTION","ROOT","FRACTION","SUBSUP",
217 "EQOVER","DELIMETER","LARGE_DELIM","DECORATION","SPACE_SYMBOL","CHARACTER","STRING",
218 "OPERATOR","EQBEGIN","EQEND","EQLEFT","EQRIGHT","NEWLINE","LEFT_DELIM","RIGHT_DELIM",
219 "DIGIT","'|'","'('","'['","'{'","'<'","')'","']'","'}'","'>'","'_'","'^'","Identifier",
220 "PrimaryExpr","EQLeft","EQRight","Fence","Parenth","Block","Bracket","SubSupExpr",
221 "FractionExpr","OverExpr","Accent","AccentExpr","Decoration","DecorationExpr",
222 "RootExpr","BeginExpr","EndExpr","MathML","Lines","Line","ExprList","Expr", NULL
224 #endif
226 static const short yyr1[] = { 0,
227 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
228 43, 43, 43, 43, 43, 43, 43, 44, 44, 45,
229 45, 45, 45, 45, 45, 45, 46, 46, 46, 46,
230 46, 46, 46, 47, 48, 48, 49, 49, 50, 50,
231 51, 51, 51, 52, 53, 54, 55, 56, 57, 58,
232 58, 59, 59, 60, 61, 62, 62, 63, 64, 64,
233 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
234 65, 65
237 static const short yyr2[] = { 0,
238 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
239 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
240 2, 2, 2, 2, 3, 1, 2, 2, 2, 2,
241 2, 3, 1, 3, 3, 2, 3, 2, 3, 2,
242 3, 3, 5, 3, 5, 1, 2, 1, 2, 2,
243 3, 2, 3, 2, 1, 1, 3, 1, 1, 2,
244 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
245 1, 1
248 static const short yydefact[] = { 0,
249 46, 1, 4, 10, 9, 14, 2, 3, 5, 6,
250 0, 0, 12, 13, 48, 7, 8, 17, 11, 0,
251 0, 0, 26, 16, 15, 0, 0, 18, 70, 0,
252 63, 62, 61, 64, 65, 66, 0, 69, 0, 67,
253 68, 71, 72, 55, 56, 58, 59, 0, 0, 50,
254 0, 0, 52, 54, 24, 20, 21, 22, 23, 36,
255 0, 38, 0, 19, 0, 47, 49, 0, 60, 0,
256 0, 40, 0, 0, 51, 44, 53, 25, 35, 0,
257 37, 0, 33, 34, 57, 61, 41, 42, 39, 0,
258 31, 27, 28, 29, 30, 0, 45, 32, 43, 0,
259 0, 0
262 static const short yydefgoto[] = { 28,
263 29, 30, 84, 31, 32, 33, 51, 34, 35, 36,
264 37, 38, 39, 40, 41, 42, 43, 100, 44, 45,
265 46, 47
268 static const short yypact[] = { 393,
269 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
270 -30, -19,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -19,
271 -19, -3,-32768,-32768,-32768, 290, 107,-32768, 425, 393,
272 -32768,-32768,-32768,-32768,-32768,-32768, -19,-32768, -19,-32768,
273 -32768,-32768,-32768, -20,-32768, 393, -21, 218, 107,-32768,
274 -19, -19, -19,-32768, -15,-32768,-32768,-32768,-32768,-32768,
275 325,-32768, 70,-32768, 360,-32768,-32768, 393, -21, 393,
276 393,-32768, 254, 144,-32768,-32768,-32768,-32768,-32768, 393,
277 -32768, -25,-32768,-32768,-32768, -31, -21, -21,-32768, 181,
278 -14,-32768,-32768,-32768,-32768, -19,-32768,-32768,-32768, 22,
279 23,-32768
282 static const short yypgoto[] = { -2,
283 -32768,-32768,-32768,-32768,-32768, -11,-32768,-32768,-32768,-32768,
284 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -33,
285 -24, -27
289 #define YYLAST 457
292 static const short yytable[] = { 50,
293 52, 61, 63, 48, 49, 65, 91, 68, 53, 54,
294 96, 92, 93, 94, 95, 49, 78, 98, 69, 70,
295 71, 101, 102, 73, 74, 66, 64, 67, 55, 56,
296 57, 58, 59, 69, 85, 69, 0, 69, 0, 75,
297 76, 77, 87, 88, 0, 69, 69, 0, 0, 0,
298 0, 0, 0, 0, 0, 90, 0, 0, 86, 0,
299 0, 0, 69, 0, 0, 0, 0, 0, 0, 0,
300 0, 0, 1, 2, 3, 4, 5, 6, 7, 8,
301 9, 10, 11, 12, 99, 80, 13, 14, 15, 16,
302 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
303 24, 25, 26, 0, 27, 0, 0, 0, 81, 1,
304 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
305 12, 0, 0, 13, 14, 15, 16, 17, 18, 19,
306 20, 21, 22, 0, 0, 23, 0, 24, 25, 26,
307 0, 27, 0, 0, 0, 62, 1, 2, 3, 4,
308 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
309 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
310 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
311 0, 0, 81, 1, 2, 3, 4, 5, 6, 7,
312 8, 9, 10, 11, 12, 0, 0, 13, 14, 15,
313 16, 17, 18, 19, 20, 21, 22, 0, 0, 23,
314 0, 24, 25, 26, 0, 27, 0, 0, 0, 97,
315 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
316 11, 12, 0, 0, 13, 14, 15, 16, 17, 18,
317 19, 20, 21, 22, 0, 0, 23, 0, 24, 25,
318 26, 0, 27, 0, 0, 72, 1, 2, 3, 4,
319 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
320 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
321 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
322 0, 89, 1, 2, 3, 4, 5, 6, 7, 8,
323 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
324 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
325 24, 25, 26, 0, 27, 0, 60, 1, 2, 3,
326 4, 5, 6, 7, 8, 9, 10, 11, 12, 0,
327 0, 13, 14, 15, 16, 17, 18, 19, 20, 21,
328 22, 0, 0, 23, 0, 24, 25, 26, 0, 27,
329 0, 79, 1, 2, 3, 4, 5, 6, 7, 8,
330 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
331 17, 18, 19, 20, 21, 22, 82, 0, 23, 83,
332 24, 25, 26, 0, 27, 1, 2, 3, 4, 5,
333 6, 7, 8, 9, 10, 11, 12, 0, 0, 13,
334 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
335 0, 23, 0, 24, 25, 26, 0, 27, 2, 3,
336 4, 5, 6, 7, 8, 9, 10, 0, 0, 0,
337 0, 13, 14, 0, 16, 17, 18, 19, 0, 0,
338 0, 0, 0, 0, 0, 24, 25
341 static const short yycheck[] = { 11,
342 12, 26, 27, 34, 35, 30, 32, 28, 20, 21,
343 42, 37, 38, 39, 40, 35, 32, 32, 46, 41,
344 42, 0, 0, 48, 49, 37, 29, 39, 32, 33,
345 34, 35, 36, 61, 68, 63, -1, 65, -1, 51,
346 52, 53, 70, 71, -1, 73, 74, -1, -1, -1,
347 -1, -1, -1, -1, -1, 80, -1, -1, 70, -1,
348 -1, -1, 90, -1, -1, -1, -1, -1, -1, -1,
349 -1, -1, 3, 4, 5, 6, 7, 8, 9, 10,
350 11, 12, 13, 14, 96, 16, 17, 18, 19, 20,
351 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
352 31, 32, 33, -1, 35, -1, -1, -1, 39, 3,
353 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
354 14, -1, -1, 17, 18, 19, 20, 21, 22, 23,
355 24, 25, 26, -1, -1, 29, -1, 31, 32, 33,
356 -1, 35, -1, -1, -1, 39, 3, 4, 5, 6,
357 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
358 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
359 -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
360 -1, -1, 39, 3, 4, 5, 6, 7, 8, 9,
361 10, 11, 12, 13, 14, -1, -1, 17, 18, 19,
362 20, 21, 22, 23, 24, 25, 26, -1, -1, 29,
363 -1, 31, 32, 33, -1, 35, -1, -1, -1, 39,
364 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
365 13, 14, -1, -1, 17, 18, 19, 20, 21, 22,
366 23, 24, 25, 26, -1, -1, 29, -1, 31, 32,
367 33, -1, 35, -1, -1, 38, 3, 4, 5, 6,
368 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
369 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
370 -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
371 -1, 38, 3, 4, 5, 6, 7, 8, 9, 10,
372 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
373 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
374 31, 32, 33, -1, 35, -1, 37, 3, 4, 5,
375 6, 7, 8, 9, 10, 11, 12, 13, 14, -1,
376 -1, 17, 18, 19, 20, 21, 22, 23, 24, 25,
377 26, -1, -1, 29, -1, 31, 32, 33, -1, 35,
378 -1, 37, 3, 4, 5, 6, 7, 8, 9, 10,
379 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
380 21, 22, 23, 24, 25, 26, 27, -1, 29, 30,
381 31, 32, 33, -1, 35, 3, 4, 5, 6, 7,
382 8, 9, 10, 11, 12, 13, 14, -1, -1, 17,
383 18, 19, 20, 21, 22, 23, 24, 25, 26, -1,
384 -1, 29, -1, 31, 32, 33, -1, 35, 4, 5,
385 6, 7, 8, 9, 10, 11, 12, -1, -1, -1,
386 -1, 17, 18, -1, 20, 21, 22, 23, -1, -1,
387 -1, -1, -1, -1, -1, 31, 32
389 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
390 #line 3 "/usr/lib/bison.simple"
391 /* This file comes from bison-1.28. */
393 /* Skeleton output parser for bison,
394 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
396 This program is free software; you can redistribute it and/or modify
397 it under the terms of the GNU General Public License as published by
398 the Free Software Foundation; either version 2, or (at your option)
399 any later version.
401 This program is distributed in the hope that it will be useful,
402 but WITHOUT ANY WARRANTY; without even the implied warranty of
403 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
404 GNU General Public License for more details.
406 You should have received a copy of the GNU General Public License
407 along with this program; if not, write to the Free Software
408 Foundation, Inc., 59 Temple Place - Suite 330,
409 Boston, MA 02111-1307, USA. */
411 /* As a special exception, when this file is copied by Bison into a
412 Bison output file, you may use that output file without restriction.
413 This special exception was added by the Free Software Foundation
414 in version 1.24 of Bison. */
416 /* This is the parser code that is written into each bison parser
417 when the %semantic_parser declaration is not specified in the grammar.
418 It was written by Richard Stallman by simplifying the hairy parser
419 used when %semantic_parser is specified. */
421 #ifndef YYSTACK_USE_ALLOCA
422 #ifdef alloca
423 #define YYSTACK_USE_ALLOCA
424 #else /* alloca not defined */
425 #ifdef __GNUC__
426 #define YYSTACK_USE_ALLOCA
427 #define alloca __builtin_alloca
428 #else /* not GNU C. */
429 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
430 #define YYSTACK_USE_ALLOCA
431 #include <sal/alloca.h>
432 #else /* not sparc */
433 /* We think this test detects Watcom and Microsoft C. */
434 /* This used to test MSDOS, but that is a bad idea
435 since that symbol is in the user namespace. */
436 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
437 #if 0 /* No need for malloc.h, which pollutes the namespace;
438 instead, just don't use alloca. */
439 #include <malloc.h>
440 #endif
441 #else /* not MSDOS, or __TURBOC__ */
442 #if defined(_AIX)
443 /* I don't know what this was needed for, but it pollutes the namespace.
444 So I turned it off. rms, 2 May 1997. */
445 /* #include <malloc.h> */
446 #pragma alloca
447 #define YYSTACK_USE_ALLOCA
448 #else /* not MSDOS, or __TURBOC__, or _AIX */
449 #if 0
450 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
451 and on HPUX 10. Eventually we can turn this on. */
452 #define YYSTACK_USE_ALLOCA
453 #define alloca __builtin_alloca
454 #endif /* __hpux */
455 #endif
456 #endif /* not _AIX */
457 #endif /* not MSDOS, or __TURBOC__ */
458 #endif /* not sparc */
459 #endif /* not GNU C */
460 #endif /* alloca not defined */
461 #endif /* YYSTACK_USE_ALLOCA not defined */
463 #ifdef YYSTACK_USE_ALLOCA
464 #define YYSTACK_ALLOC alloca
465 #else
466 #define YYSTACK_ALLOC malloc
467 #endif
469 /* Note: there must be only one dollar sign in this file.
470 It is replaced by the list of actions, each action
471 as one case of the switch. */
473 #define yyerrok (yyerrstatus = 0)
474 #define yyclearin (yychar = YYEMPTY)
475 #define YYEMPTY -2
476 #define YYEOF 0
477 #define YYACCEPT goto yyacceptlab
478 #define YYABORT goto yyabortlab
479 #define YYERROR goto yyerrlab1
480 /* Like YYERROR except do call yyerror.
481 This remains here temporarily to ease the
482 transition to the new meaning of YYERROR, for GCC.
483 Once GCC version 2 has supplanted version 1, this can go. */
484 #define YYFAIL goto yyerrlab
485 #define YYRECOVERING() (!!yyerrstatus)
486 #define YYBACKUP(token, value) \
487 do \
488 if (yychar == YYEMPTY && yylen == 1) \
489 { yychar = (token), yylval = (value); \
490 yychar1 = YYTRANSLATE (yychar); \
491 YYPOPSTACK; \
492 goto yybackup; \
494 else \
495 { yyerror ("syntax error: cannot back up"); YYERROR; } \
496 while (0)
498 #define YYTERROR 1
499 #define YYERRCODE 256
501 #ifndef YYPURE
502 #define YYLEX yylex()
503 #endif
505 #ifdef YYPURE
506 #ifdef YYLSP_NEEDED
507 #ifdef YYLEX_PARAM
508 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
509 #else
510 #define YYLEX yylex(&yylval, &yylloc)
511 #endif
512 #else /* not YYLSP_NEEDED */
513 #ifdef YYLEX_PARAM
514 #define YYLEX yylex(&yylval, YYLEX_PARAM)
515 #else
516 #define YYLEX yylex(&yylval)
517 #endif
518 #endif /* not YYLSP_NEEDED */
519 #endif
521 /* If nonreentrant, generate the variables here */
523 #ifndef YYPURE
525 int yychar; /* the lookahead symbol */
526 YYSTYPE yylval; /* the semantic value of the */
527 /* lookahead symbol */
529 #ifdef YYLSP_NEEDED
530 YYLTYPE yylloc; /* location data for the lookahead */
531 /* symbol */
532 #endif
534 int yynerrs; /* number of parse errors so far */
535 #endif /* not YYPURE */
537 #if YYDEBUG != 0
538 int yydebug; /* nonzero means print parse trace */
539 /* Since this is uninitialized, it does not stop multiple parsers
540 from coexisting. */
541 #endif
543 /* YYINITDEPTH indicates the initial size of the parser's stacks */
545 #ifndef YYINITDEPTH
546 #define YYINITDEPTH 200
547 #endif
549 /* YYMAXDEPTH is the maximum size the stacks can grow to
550 (effective only if the built-in stack extension method is used). */
552 #if YYMAXDEPTH == 0
553 #undef YYMAXDEPTH
554 #endif
556 #ifndef YYMAXDEPTH
557 #define YYMAXDEPTH 10000
558 #endif
560 /* Define __yy_memcpy. Note that the size argument
561 should be passed with type unsigned int, because that is what the non-GCC
562 definitions require. With GCC, __builtin_memcpy takes an arg
563 of type size_t, but it can handle unsigned int. */
565 #if defined __GNUC__
566 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
567 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
568 #endif
569 #else /* not GNU C or C++ */
570 #ifndef __cplusplus
572 /* This is the most reliable way to avoid incompatibilities
573 in available built-in functions on various systems. */
574 static void
575 __yy_memcpy (to, from, count)
576 char *to;
577 char *from;
578 unsigned int count;
580 register char *f = from;
581 register char *t = to;
582 register int i = count;
584 while (i-- > 0)
585 *t++ = *f++;
588 #else /* __cplusplus */
590 /* This is the most reliable way to avoid incompatibilities
591 in available built-in functions on various systems. */
592 static void
593 __yy_memcpy (char *to, char *from, unsigned int count)
595 register char *t = to;
596 register char *f = from;
597 register int i = count;
599 while (i-- > 0)
600 *t++ = *f++;
603 #endif
604 #endif
606 #line 217 "/usr/lib/bison.simple"
608 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
609 into yyparse. The argument should have type void *.
610 It should actually point to an object.
611 Grammar actions can access the variable by casting it
612 to the proper pointer type. */
614 #ifdef YYPARSE_PARAM
615 #ifdef __cplusplus
616 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
617 #define YYPARSE_PARAM_DECL
618 #else /* not __cplusplus */
619 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
620 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
621 #endif /* not __cplusplus */
622 #else /* not YYPARSE_PARAM */
623 #define YYPARSE_PARAM_ARG
624 #define YYPARSE_PARAM_DECL
625 #endif /* not YYPARSE_PARAM */
627 /* Prevent warning if -Wstrict-prototypes. */
628 #ifdef __GNUC__
629 #ifdef YYPARSE_PARAM
630 int yyparse (void *);
631 #else
632 int yyparse (void);
633 #endif
634 #endif
637 yyparse(YYPARSE_PARAM_ARG)
638 YYPARSE_PARAM_DECL
640 register int yystate;
641 register int yyn;
642 register short *yyssp;
643 register YYSTYPE *yyvsp;
644 int yyerrstatus; /* number of tokens to shift before error messages enabled */
645 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
647 short yyssa[YYINITDEPTH]; /* the state stack */
648 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
650 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
651 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
653 #ifdef YYLSP_NEEDED
654 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
655 YYLTYPE *yyls = yylsa;
656 YYLTYPE *yylsp;
658 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
659 #else
660 #define YYPOPSTACK (yyvsp--, yyssp--)
661 #endif
663 int yystacksize = YYINITDEPTH;
664 int yyfree_stacks = 0;
666 #ifdef YYPURE
667 int yychar;
668 YYSTYPE yylval;
669 int yynerrs;
670 #ifdef YYLSP_NEEDED
671 YYLTYPE yylloc;
672 #endif
673 #endif
675 YYSTYPE yyval; /* the variable used to return */
676 yyval.dval = 0;
677 /* semantic values from the action */
678 /* routines */
680 int yylen;
682 #if YYDEBUG != 0
683 if (yydebug)
684 fprintf(stderr, "Starting parse\n");
685 #endif
687 yystate = 0;
688 yyerrstatus = 0;
689 yynerrs = 0;
690 yychar = YYEMPTY; /* Cause a token to be read. */
692 /* Initialize stack pointers.
693 Waste one element of value and location stack
694 so that they stay on the same level as the state stack.
695 The wasted elements are never initialized. */
697 yyssp = yyss - 1;
698 yyvsp = yyvs;
699 #ifdef YYLSP_NEEDED
700 yylsp = yyls;
701 #endif
703 /* Push a new state, which is found in yystate . */
704 /* In all cases, when you get here, the value and location stacks
705 have just been pushed. so pushing a state here evens the stacks. */
706 yynewstate:
708 *++yyssp = sal::static_int_cast<short>(yystate);
710 if (yyssp >= yyss + yystacksize - 1)
712 /* Give user a chance to reallocate the stack */
713 /* Use copies of these so that the &'s don't force the real ones into memory. */
714 YYSTYPE *yyvs1 = yyvs;
715 short *yyss1 = yyss;
716 #ifdef YYLSP_NEEDED
717 YYLTYPE *yyls1 = yyls;
718 #endif
720 /* Get the current used size of the three stacks, in elements. */
721 int size = yyssp - yyss + 1;
723 #ifdef yyoverflow
724 /* Each stack pointer address is followed by the size of
725 the data in use in that stack, in bytes. */
726 #ifdef YYLSP_NEEDED
727 /* This used to be a conditional around just the two extra args,
728 but that might be undefined if yyoverflow is a macro. */
729 yyoverflow("parser stack overflow",
730 &yyss1, size * sizeof (*yyssp),
731 &yyvs1, size * sizeof (*yyvsp),
732 &yyls1, size * sizeof (*yylsp),
733 &yystacksize);
734 #else
735 yyoverflow("parser stack overflow",
736 &yyss1, size * sizeof (*yyssp),
737 &yyvs1, size * sizeof (*yyvsp),
738 &yystacksize);
739 #endif
741 yyss = yyss1; yyvs = yyvs1;
742 #ifdef YYLSP_NEEDED
743 yyls = yyls1;
744 #endif
745 #else /* no yyoverflow */
746 /* Extend the stack our own way. */
747 if (yystacksize >= YYMAXDEPTH)
749 yyerror("parser stack overflow");
750 if (yyfree_stacks)
752 free (yyss);
753 free (yyvs);
754 #ifdef YYLSP_NEEDED
755 free (yyls);
756 #endif
758 return 2;
760 yystacksize *= 2;
761 if (yystacksize > YYMAXDEPTH)
762 yystacksize = YYMAXDEPTH;
763 #ifndef YYSTACK_USE_ALLOCA
764 yyfree_stacks = 1;
765 #endif
766 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
767 __yy_memcpy ((char *)yyss, (char *)yyss1,
768 size * (unsigned int) sizeof (*yyssp));
769 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
770 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
771 size * (unsigned int) sizeof (*yyvsp));
772 #ifdef YYLSP_NEEDED
773 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
774 __yy_memcpy ((char *)yyls, (char *)yyls1,
775 size * (unsigned int) sizeof (*yylsp));
776 #endif
777 #endif /* no yyoverflow */
779 yyssp = yyss + size - 1;
780 yyvsp = yyvs + size - 1;
781 #ifdef YYLSP_NEEDED
782 yylsp = yyls + size - 1;
783 #endif
785 #if YYDEBUG != 0
786 if (yydebug)
787 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
788 #endif
790 if (yyssp >= yyss + yystacksize - 1)
791 YYABORT;
794 #if YYDEBUG != 0
795 if (yydebug)
796 fprintf(stderr, "Entering state %d\n", yystate);
797 #endif
799 goto yybackup;
800 yybackup:
802 /* Do appropriate processing given the current state. */
803 /* Read a lookahead token if we need one and don't already have one. */
804 /* yyresume: */
806 /* First try to decide what to do without reference to lookahead token. */
808 yyn = yypact[yystate];
809 if (yyn == YYFLAG)
810 goto yydefault;
812 /* Not known => get a lookahead token if don't already have one. */
814 /* yychar is either YYEMPTY or YYEOF
815 or a valid token in external form. */
817 if (yychar == YYEMPTY)
819 #if YYDEBUG != 0
820 if (yydebug)
821 fprintf(stderr, "Reading a token: ");
822 #endif
823 yychar = YYLEX;
826 /* Convert token to internal form (in yychar1) for indexing tables with */
828 if (yychar <= 0) /* This means end of input. */
830 yychar1 = 0;
831 yychar = YYEOF; /* Don't call YYLEX any more */
833 #if YYDEBUG != 0
834 if (yydebug)
835 fprintf(stderr, "Now at end of input.\n");
836 #endif
838 else
840 yychar1 = YYTRANSLATE(yychar);
842 #if YYDEBUG != 0
843 if (yydebug)
845 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
846 /* Give the individual parser a way to print the precise meaning
847 of a token, for further debugging info. */
848 #ifdef YYPRINT
849 YYPRINT (stderr, yychar, yylval);
850 #endif
851 fprintf (stderr, ")\n");
853 #endif
856 yyn += yychar1;
857 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
858 goto yydefault;
860 yyn = yytable[yyn];
862 /* yyn is what to do for this token type in this state.
863 Negative => reduce, -yyn is rule number.
864 Positive => shift, yyn is new state.
865 New state is final state => don't bother to shift,
866 just return success.
867 0, or most negative number => error. */
869 if (yyn < 0)
871 if (yyn == YYFLAG)
872 goto yyerrlab;
873 yyn = -yyn;
874 goto yyreduce;
876 else if (yyn == 0)
877 goto yyerrlab;
879 if (yyn == YYFINAL)
880 YYACCEPT;
882 /* Shift the lookahead token. */
884 #if YYDEBUG != 0
885 if (yydebug)
886 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
887 #endif
889 /* Discard the token being shifted unless it is eof. */
890 if (yychar != YYEOF)
891 yychar = YYEMPTY;
893 *++yyvsp = yylval;
894 #ifdef YYLSP_NEEDED
895 *++yylsp = yylloc;
896 #endif
898 /* count tokens shifted since error; after three, turn off error status. */
899 if (yyerrstatus) yyerrstatus--;
901 yystate = yyn;
902 goto yynewstate;
904 /* Do the default action for the current state. */
905 yydefault:
907 yyn = yydefact[yystate];
908 if (yyn == 0)
909 goto yyerrlab;
911 /* Do a reduction. yyn is the number of a rule to reduce with. */
912 yyreduce:
913 yylen = yyr2[yyn];
914 if (yylen > 0)
915 yyval = yyvsp[1-yylen]; /* implement default value of the action */
917 #if YYDEBUG != 0
918 if (yydebug)
920 int i;
922 fprintf (stderr, "Reducing via rule %d (line %d), ",
923 yyn, yyrline[yyn]);
925 /* Print the symbols being reduced, and their result. */
926 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
927 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
928 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
930 #endif
933 switch (yyn) {
935 case 1:
936 #line 60 "grammar.y"
937 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
938 break;}
939 case 2:
940 #line 61 "grammar.y"
941 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
942 break;}
943 case 3:
944 #line 62 "grammar.y"
945 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
946 break;}
947 case 4:
948 #line 63 "grammar.y"
949 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
950 break;}
951 case 5:
952 #line 64 "grammar.y"
953 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
954 break;}
955 case 6:
956 #line 65 "grammar.y"
957 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
958 break;}
959 case 7:
960 #line 66 "grammar.y"
961 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
962 break;}
963 case 8:
964 #line 67 "grammar.y"
965 { yyval.ptr = new Node(ID_CHARACTER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
966 break;}
967 case 9:
968 #line 68 "grammar.y"
969 { yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
970 break;}
971 case 10:
972 #line 69 "grammar.y"
973 { yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
974 break;}
975 case 11:
976 #line 70 "grammar.y"
977 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
978 break;}
979 case 12:
980 #line 71 "grammar.y"
981 { yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
982 break;}
983 case 13:
984 #line 72 "grammar.y"
985 { yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
986 break;}
987 case 14:
988 #line 73 "grammar.y"
989 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
990 break;}
991 case 15:
992 #line 74 "grammar.y"
993 { yyval.ptr = new Node(ID_CHARACTER); allocChar(yyval.ptr->value , '|'); debug("Identifier : '|'\n"); nodelist.insert(yyval.ptr); ;
994 break;}
995 case 16:
996 #line 75 "grammar.y"
997 { yyval.ptr = new Node(ID_NUMBER); allocValue(yyval.ptr->value , yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.insert(yyval.ptr); ;
998 break;}
999 case 17:
1000 #line 76 "grammar.y"
1001 { yyval.ptr = new Node(ID_STRING); allocValue(yyval.ptr->value , yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
1002 break;}
1003 case 18:
1004 #line 80 "grammar.y"
1005 { yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.insert(yyval.ptr); ;
1006 break;}
1007 case 19:
1008 #line 81 "grammar.y"
1009 { yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyval.ptr->next = yyvsp[0].ptr; debug("PrimaryExpr : PrimaryExpr Identifier\n"); nodelist.insert(yyval.ptr); ;
1010 break;}
1011 case 20:
1012 #line 85 "grammar.y"
1013 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '('); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
1014 break;}
1015 case 21:
1016 #line 86 "grammar.y"
1017 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '['); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
1018 break;}
1019 case 22:
1020 #line 87 "grammar.y"
1021 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '{'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
1022 break;}
1023 case 23:
1024 #line 88 "grammar.y"
1025 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '<'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
1026 break;}
1027 case 24:
1028 #line 89 "grammar.y"
1029 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '|'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
1030 break;}
1031 case 25:
1032 #line 90 "grammar.y"
1033 { yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , "||"); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
1034 break;}
1035 case 26:
1036 #line 91 "grammar.y"
1037 { yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
1038 break;}
1039 case 27:
1040 #line 95 "grammar.y"
1041 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ')'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
1042 break;}
1043 case 28:
1044 #line 96 "grammar.y"
1045 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ']'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
1046 break;}
1047 case 29:
1048 #line 97 "grammar.y"
1049 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '}'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
1050 break;}
1051 case 30:
1052 #line 98 "grammar.y"
1053 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '>'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
1054 break;}
1055 case 31:
1056 #line 99 "grammar.y"
1057 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '|'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
1058 break;}
1059 case 32:
1060 #line 100 "grammar.y"
1061 { yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , "||"); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
1062 break;}
1063 case 33:
1064 #line 101 "grammar.y"
1065 { yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
1066 break;}
1067 case 34:
1068 #line 105 "grammar.y"
1069 { yyval.ptr = new Node(ID_FENCE); yyval.ptr->child=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[-1].ptr; yyvsp[-1].ptr->next=yyvsp[0].ptr; debug("Fence \n"); nodelist.insert(yyval.ptr); ;
1070 break;}
1071 case 35:
1072 #line 109 "grammar.y"
1073 { yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.insert(yyval.ptr); ;
1074 break;}
1075 case 36:
1076 #line 110 "grammar.y"
1077 { yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.insert(yyval.ptr); ;
1078 break;}
1079 case 37:
1080 #line 114 "grammar.y"
1081 { yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.insert(yyval.ptr); ;
1082 break;}
1083 case 38:
1084 #line 115 "grammar.y"
1085 { yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.insert(yyval.ptr); ;
1086 break;}
1087 case 39:
1088 #line 119 "grammar.y"
1089 { yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.insert(yyval.ptr); ;
1090 break;}
1091 case 40:
1092 #line 120 "grammar.y"
1093 { yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.insert(yyval.ptr); ;
1094 break;}
1095 case 41:
1096 #line 124 "grammar.y"
1097 { yyval.ptr = new Node(ID_SUBEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUBEXPR\n"); nodelist.insert(yyval.ptr); ;
1098 break;}
1099 case 42:
1100 #line 125 "grammar.y"
1101 { yyval.ptr = new Node(ID_SUPEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUPEXPR\n"); nodelist.insert(yyval.ptr); ;
1102 break;}
1103 case 43:
1104 #line 126 "grammar.y"
1105 { yyval.ptr = new Node(ID_SUBSUPEXPR); yyval.ptr->child=yyvsp[-4].ptr; yyvsp[-4].ptr->next=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[0].ptr; debug("SubSupExpr : ID_SUBSUPEXPR\n"); nodelist.insert(yyval.ptr); ;
1106 break;}
1107 case 44:
1108 #line 130 "grammar.y"
1109 { yyval.ptr = new Node(ID_FRACTIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("FractionExpr : %s\n",yyvsp[-2].str); nodelist.insert(yyval.ptr); ;
1110 break;}
1111 case 45:
1112 #line 134 "grammar.y"
1113 { yyval.ptr = new Node(ID_OVER); yyval.ptr->child = yyvsp[-3].ptr; yyvsp[-3].ptr->next = yyvsp[-1].ptr; debug("OverExpr\n"); nodelist.insert(yyval.ptr); ;
1114 break;}
1115 case 46:
1116 #line 139 "grammar.y"
1117 { yyval.ptr = new Node(ID_ACCENTEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ;
1118 break;}
1119 case 47:
1120 #line 143 "grammar.y"
1121 { yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->child=yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("AccentExpr \n"); nodelist.insert(yyval.ptr); ;
1122 break;}
1123 case 48:
1124 #line 146 "grammar.y"
1125 { yyval.ptr = new Node(ID_DECORATIONEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ;
1126 break;}
1127 case 49:
1128 #line 150 "grammar.y"
1129 { yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("DecorationExpr \n"); nodelist.insert(yyval.ptr); ;
1130 break;}
1131 case 50:
1132 #line 154 "grammar.y"
1133 { yyval.ptr = new Node(ID_SQRTEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-1].str); nodelist.insert(yyval.ptr); ;
1134 break;}
1135 case 51:
1136 #line 155 "grammar.y"
1137 { yyval.ptr = new Node(ID_ROOTEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-2].str); nodelist.insert(yyval.ptr); ;
1138 break;}
1139 case 52:
1140 #line 159 "grammar.y"
1141 { yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ;
1142 break;}
1143 case 53:
1144 #line 160 "grammar.y"
1145 { yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ;
1146 break;}
1147 case 54:
1148 #line 164 "grammar.y"
1149 { yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("EndExpr\n"); ;
1150 break;}
1151 case 55:
1152 #line 169 "grammar.y"
1153 { yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); top = yyval.ptr; debug("MathML\n"); ;
1154 break;}
1155 case 56:
1156 #line 173 "grammar.y"
1157 { yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ;
1158 break;}
1159 case 57:
1160 #line 174 "grammar.y"
1161 { yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ;
1162 break;}
1163 case 58:
1164 #line 178 "grammar.y"
1165 { yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Line\n"); ;
1166 break;}
1167 case 59:
1168 #line 182 "grammar.y"
1169 { yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.insert(yyval.ptr); ;
1170 break;}
1171 case 60:
1172 #line 183 "grammar.y"
1173 { yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("ExprList : ExprList Expr\n"); nodelist.insert(yyval.ptr); ;
1174 break;}
1175 case 61:
1176 #line 187 "grammar.y"
1177 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.insert(yyval.ptr);;
1178 break;}
1179 case 62:
1180 #line 188 "grammar.y"
1181 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.insert(yyval.ptr);;
1182 break;}
1183 case 63:
1184 #line 189 "grammar.y"
1185 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.insert(yyval.ptr);;
1186 break;}
1187 case 64:
1188 #line 190 "grammar.y"
1189 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.insert(yyval.ptr);;
1190 break;}
1191 case 65:
1192 #line 191 "grammar.y"
1193 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.insert(yyval.ptr);;
1194 break;}
1195 case 66:
1196 #line 192 "grammar.y"
1197 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.insert(yyval.ptr);;
1198 break;}
1199 case 67:
1200 #line 193 "grammar.y"
1201 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.insert(yyval.ptr);;
1202 break;}
1203 case 68:
1204 #line 194 "grammar.y"
1205 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.insert(yyval.ptr);;
1206 break;}
1207 case 69:
1208 #line 195 "grammar.y"
1209 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.insert(yyval.ptr);;
1210 break;}
1211 case 70:
1212 #line 196 "grammar.y"
1213 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.insert(yyval.ptr);;
1214 break;}
1215 case 71:
1216 #line 197 "grammar.y"
1217 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.insert(yyval.ptr);;
1218 break;}
1219 case 72:
1220 #line 198 "grammar.y"
1221 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.insert(yyval.ptr);;
1222 break;}
1224 /* the action file gets copied in in place of this dollarsign */
1225 #line 543 "/usr/lib/bison.simple"
1227 yyvsp -= yylen;
1228 yyssp -= yylen;
1229 #ifdef YYLSP_NEEDED
1230 yylsp -= yylen;
1231 #endif
1233 #if YYDEBUG != 0
1234 if (yydebug)
1236 short *ssp1 = yyss - 1;
1237 fprintf (stderr, "state stack now");
1238 while (ssp1 != yyssp)
1239 fprintf (stderr, " %d", *++ssp1);
1240 fprintf (stderr, "\n");
1242 #endif
1244 *++yyvsp = yyval;
1246 #ifdef YYLSP_NEEDED
1247 yylsp++;
1248 if (yylen == 0)
1250 yylsp->first_line = yylloc.first_line;
1251 yylsp->first_column = yylloc.first_column;
1252 yylsp->last_line = (yylsp-1)->last_line;
1253 yylsp->last_column = (yylsp-1)->last_column;
1254 yylsp->text = 0;
1256 else
1258 yylsp->last_line = (yylsp+yylen-1)->last_line;
1259 yylsp->last_column = (yylsp+yylen-1)->last_column;
1261 #endif
1263 /* Now "shift" the result of the reduction.
1264 Determine what state that goes to,
1265 based on the state we popped back to
1266 and the rule number reduced by. */
1268 yyn = yyr1[yyn];
1270 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1271 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1272 yystate = yytable[yystate];
1273 else
1274 yystate = yydefgoto[yyn - YYNTBASE];
1276 goto yynewstate;
1278 yyerrlab: /* here on detecting error */
1280 if (! yyerrstatus)
1281 /* If not already recovering from an error, report this error. */
1283 ++yynerrs;
1285 #ifdef YYERROR_VERBOSE
1286 yyn = yypact[yystate];
1288 if (yyn > YYFLAG && yyn < YYLAST)
1290 int size = 0;
1291 char *msg;
1292 int x, count;
1294 count = 0;
1295 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1296 for (x = (yyn < 0 ? -yyn : 0);
1297 x < (sizeof(yytname) / sizeof(char *)); x++)
1298 if (yycheck[x + yyn] == x)
1299 size += strlen(yytname[x]) + 15, count++;
1300 msg = (char *) malloc(size + 15);
1301 if (msg != 0)
1303 strcpy(msg, "parse error");
1305 if (count < 5)
1307 count = 0;
1308 for (x = (yyn < 0 ? -yyn : 0);
1309 x < (sizeof(yytname) / sizeof(char *)); x++)
1310 if (yycheck[x + yyn] == x)
1312 strcat(msg, count == 0 ? ", expecting `" : " or `");
1313 strcat(msg, yytname[x]);
1314 strcat(msg, "'");
1315 count++;
1318 yyerror(msg);
1319 free(msg);
1321 else
1322 yyerror ("parse error; also virtual memory exceeded");
1324 else
1325 #endif /* YYERROR_VERBOSE */
1326 yyerror("parse error");
1329 goto yyerrlab1;
1330 yyerrlab1: /* here on error raised explicitly by an action */
1332 if (yyerrstatus == 3)
1334 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1336 /* return failure if at end of input */
1337 if (yychar == YYEOF)
1338 YYABORT;
1340 #if YYDEBUG != 0
1341 if (yydebug)
1342 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1343 #endif
1345 yychar = YYEMPTY;
1348 /* Else will try to reuse lookahead token
1349 after shifting the error token. */
1351 yyerrstatus = 3; /* Each real token shifted decrements this */
1353 goto yyerrhandle;
1355 yyerrdefault: /* current state does not do anything special for the error token. */
1357 #if 0
1358 /* This is wrong; only states that explicitly want error tokens
1359 should shift them. */
1360 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1361 if (yyn) goto yydefault;
1362 #endif
1364 yyerrpop: /* pop the current state because it cannot handle the error token */
1366 if (yyssp == yyss) YYABORT;
1367 yyvsp--;
1368 yystate = *--yyssp;
1369 #ifdef YYLSP_NEEDED
1370 yylsp--;
1371 #endif
1373 #if YYDEBUG != 0
1374 if (yydebug)
1376 short *ssp1 = yyss - 1;
1377 fprintf (stderr, "Error: state stack now");
1378 while (ssp1 != yyssp)
1379 fprintf (stderr, " %d", *++ssp1);
1380 fprintf (stderr, "\n");
1382 #endif
1384 yyerrhandle:
1386 yyn = yypact[yystate];
1387 if (yyn == YYFLAG)
1388 goto yyerrdefault;
1390 yyn += YYTERROR;
1391 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1392 goto yyerrdefault;
1394 yyn = yytable[yyn];
1395 if (yyn < 0)
1397 if (yyn == YYFLAG)
1398 goto yyerrpop;
1399 yyn = -yyn;
1400 goto yyreduce;
1402 else if (yyn == 0)
1403 goto yyerrpop;
1405 if (yyn == YYFINAL)
1406 YYACCEPT;
1408 #if YYDEBUG != 0
1409 if (yydebug)
1410 fprintf(stderr, "Shifting error token, ");
1411 #endif
1413 *++yyvsp = yylval;
1414 #ifdef YYLSP_NEEDED
1415 *++yylsp = yylloc;
1416 #endif
1418 yystate = yyn;
1419 goto yynewstate;
1421 yyacceptlab:
1422 /* YYACCEPT comes here. */
1423 if (yyfree_stacks)
1425 free (yyss);
1426 free (yyvs);
1427 #ifdef YYLSP_NEEDED
1428 free (yyls);
1429 #endif
1431 return 0;
1433 yyabortlab:
1434 /* YYABORT comes here. */
1435 if (yyfree_stacks)
1437 free (yyss);
1438 free (yyvs);
1439 #ifdef YYLSP_NEEDED
1440 free (yyls);
1441 #endif
1443 return 1;
1445 #line 202 "grammar.y"
1448 Node *mainParse(const char *_code)
1450 initFlex( _code );
1451 top = 0L;
1452 yyparse();
1453 if( top )
1454 return top;
1455 else
1456 return 0L;
1459 void yyerror(const char * /*err*/)
1461 // printf("REALKING ERR[%s]\n",err);
1462 // if error, delete all nodes.
1463 Node *pNode = 0L;
1464 int ncount = nodelist.count();
1465 for( int i = 0 ; i < ncount ; i++){
1466 pNode = nodelist.remove(0);
1467 delete pNode;
1469 top = 0L;
1472 #ifndef PARSE_DEBUG
1473 int debug(const char * /*format*/, ...)
1475 return 0;
1477 #endif