bump product version to 4.1.6.2
[LibreOffice.git] / hwpfilter / source / grammar.cxx
blobaf263883b025209da40512b754b2ed89b0d16748
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 /* A Bison parser, made from grammar.y
22 by GNU Bison version 1.28 */
24 #ifndef YYDEBUG
25 #define YYDEBUG 0
26 #endif
27 #ifndef YYMAXDEPTH
28 #define YYMAXDEPTH 0
29 #endif
31 #include <list>
32 #include <stdlib.h>
33 #include <string.h>
35 #include "nodes.h"
37 std::list<Node*> nodelist;
39 Node *mainParse(const char *_code);
40 void yyerror(const char *);
41 int yylex();
42 void initFlex( const char *s );
43 void viewResult(Node *res);
45 Node *top=0L;
47 int Node::count = 0;
49 #define allocValue(x,y) \
50 x = (char *)malloc( strlen(y) +1 ); \
51 strcpy(x,y)
53 #define allocChar(x,y) \
54 x = (char *)malloc(2); \
55 sprintf(x,"%c",y)
56 #ifdef PARSE_DEBUG
57 #define debug printf
58 #else
59 int debug(const char *format, ...);
60 #endif
63 typedef union {
64 char *dval;
65 char *str;
66 Node *ptr;
67 } YYSTYPE;
68 #include <stdio.h>
70 #ifndef __cplusplus
71 #ifndef __STDC__
72 #define const
73 #endif
74 #endif
78 #define YYFINAL 102
79 #define YYFLAG -32768
80 #define YYNTBASE 43
82 #define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66)
84 static const char yytranslate[] = { 0,
85 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
87 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88 2, 2, 2, 2, 2, 2, 2, 2, 2, 33,
89 37, 2, 2, 2, 2, 2, 2, 2, 2, 2,
90 2, 2, 2, 2, 2, 2, 2, 2, 2, 36,
91 2, 40, 2, 2, 2, 2, 2, 2, 2, 2,
92 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 34, 2, 38, 42, 41, 2, 2, 2, 2, 2,
95 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
96 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
97 2, 2, 35, 32, 39, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
103 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
105 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
106 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
107 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
108 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
109 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
110 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
111 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
112 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
113 27, 28, 29, 30, 31
116 #if YYDEBUG != 0
117 static const short yyprhs[] = { 0,
118 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
119 20, 22, 24, 26, 28, 30, 32, 34, 36, 39,
120 42, 45, 48, 51, 54, 58, 60, 63, 66, 69,
121 72, 75, 79, 81, 85, 89, 92, 96, 99, 103,
122 106, 110, 114, 120, 124, 130, 132, 135, 137, 140,
123 143, 147, 150, 154, 157, 159, 161, 165, 167, 169,
124 172, 174, 176, 178, 180, 182, 184, 186, 188, 190,
125 192, 194
128 static const short yyrhs[] = { 4,
129 0, 9, 0, 10, 0, 5, 0, 11, 0, 12,
130 0, 20, 0, 21, 0, 7, 0, 6, 0, 23,
131 0, 17, 0, 18, 0, 8, 0, 32, 0, 31,
132 0, 22, 0, 43, 0, 44, 43, 0, 26, 33,
133 0, 26, 34, 0, 26, 35, 0, 26, 36, 0,
134 26, 32, 0, 26, 32, 32, 0, 29, 0, 27,
135 37, 0, 27, 38, 0, 27, 39, 0, 27, 40,
136 0, 27, 32, 0, 27, 32, 32, 0, 30, 0,
137 45, 64, 46, 0, 33, 64, 37, 0, 33, 37,
138 0, 35, 64, 39, 0, 35, 39, 0, 34, 64,
139 38, 0, 34, 38, 0, 65, 41, 65, 0, 65,
140 42, 65, 0, 65, 41, 49, 42, 49, 0, 14,
141 49, 49, 0, 35, 64, 16, 64, 39, 0, 3,
142 0, 54, 49, 0, 19, 0, 56, 49, 0, 13,
143 49, 0, 13, 50, 49, 0, 24, 49, 0, 24,
144 49, 49, 0, 25, 49, 0, 62, 0, 63, 0,
145 62, 28, 63, 0, 64, 0, 65, 0, 64, 65,
146 0, 49, 0, 48, 0, 47, 0, 51, 0, 52,
147 0, 53, 0, 57, 0, 58, 0, 55, 0, 44,
148 0, 59, 0, 60, 0
151 #endif
153 #if YYDEBUG != 0
154 static const short yyrline[] = { 0,
155 59, 61, 62, 63, 64, 65, 66, 67, 68, 69,
156 70, 71, 72, 73, 74, 75, 76, 79, 81, 84,
157 86, 87, 88, 89, 90, 91, 94, 96, 97, 98,
158 99, 100, 101, 104, 108, 110, 113, 115, 118, 120,
159 123, 125, 126, 129, 133, 138, 142, 145, 149, 153,
160 155, 158, 160, 163, 168, 172, 174, 177, 181, 183,
161 186, 188, 189, 190, 191, 192, 193, 194, 195, 196,
162 197, 198
164 #endif
167 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
169 static const char * const yytname[] = { "$","error","$undefined.","ACCENT",
170 "SMALL_GREEK","CAPITAL_GREEK","BINARY_OPERATOR","RELATION_OPERATOR","ARROW",
171 "GENERAL_IDEN","GENERAL_OPER","BIG_SYMBOL","FUNCTION","ROOT","FRACTION","SUBSUP",
172 "EQOVER","DELIMETER","LARGE_DELIM","DECORATION","SPACE_SYMBOL","CHARACTER","STRING",
173 "OPERATOR","EQBEGIN","EQEND","EQLEFT","EQRIGHT","NEWLINE","LEFT_DELIM","RIGHT_DELIM",
174 "DIGIT","'|'","'('","'['","'{'","'<'","')'","']'","'}'","'>'","'_'","'^'","Identifier",
175 "PrimaryExpr","EQLeft","EQRight","Fence","Parenth","Block","Bracket","SubSupExpr",
176 "FractionExpr","OverExpr","Accent","AccentExpr","Decoration","DecorationExpr",
177 "RootExpr","BeginExpr","EndExpr","MathML","Lines","Line","ExprList","Expr", NULL
179 #endif
181 static const short yyr1[] = { 0,
182 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
183 43, 43, 43, 43, 43, 43, 43, 44, 44, 45,
184 45, 45, 45, 45, 45, 45, 46, 46, 46, 46,
185 46, 46, 46, 47, 48, 48, 49, 49, 50, 50,
186 51, 51, 51, 52, 53, 54, 55, 56, 57, 58,
187 58, 59, 59, 60, 61, 62, 62, 63, 64, 64,
188 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
189 65, 65
192 static const short yyr2[] = { 0,
193 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
194 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
195 2, 2, 2, 2, 3, 1, 2, 2, 2, 2,
196 2, 3, 1, 3, 3, 2, 3, 2, 3, 2,
197 3, 3, 5, 3, 5, 1, 2, 1, 2, 2,
198 3, 2, 3, 2, 1, 1, 3, 1, 1, 2,
199 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
200 1, 1
203 static const short yydefact[] = { 0,
204 46, 1, 4, 10, 9, 14, 2, 3, 5, 6,
205 0, 0, 12, 13, 48, 7, 8, 17, 11, 0,
206 0, 0, 26, 16, 15, 0, 0, 18, 70, 0,
207 63, 62, 61, 64, 65, 66, 0, 69, 0, 67,
208 68, 71, 72, 55, 56, 58, 59, 0, 0, 50,
209 0, 0, 52, 54, 24, 20, 21, 22, 23, 36,
210 0, 38, 0, 19, 0, 47, 49, 0, 60, 0,
211 0, 40, 0, 0, 51, 44, 53, 25, 35, 0,
212 37, 0, 33, 34, 57, 61, 41, 42, 39, 0,
213 31, 27, 28, 29, 30, 0, 45, 32, 43, 0,
214 0, 0
217 static const short yydefgoto[] = { 28,
218 29, 30, 84, 31, 32, 33, 51, 34, 35, 36,
219 37, 38, 39, 40, 41, 42, 43, 100, 44, 45,
220 46, 47
223 static const short yypact[] = { 393,
224 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
225 -30, -19,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -19,
226 -19, -3,-32768,-32768,-32768, 290, 107,-32768, 425, 393,
227 -32768,-32768,-32768,-32768,-32768,-32768, -19,-32768, -19,-32768,
228 -32768,-32768,-32768, -20,-32768, 393, -21, 218, 107,-32768,
229 -19, -19, -19,-32768, -15,-32768,-32768,-32768,-32768,-32768,
230 325,-32768, 70,-32768, 360,-32768,-32768, 393, -21, 393,
231 393,-32768, 254, 144,-32768,-32768,-32768,-32768,-32768, 393,
232 -32768, -25,-32768,-32768,-32768, -31, -21, -21,-32768, 181,
233 -14,-32768,-32768,-32768,-32768, -19,-32768,-32768,-32768, 22,
234 23,-32768
237 static const short yypgoto[] = { -2,
238 -32768,-32768,-32768,-32768,-32768, -11,-32768,-32768,-32768,-32768,
239 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -33,
240 -24, -27
244 #define YYLAST 457
247 static const short yytable[] = { 50,
248 52, 61, 63, 48, 49, 65, 91, 68, 53, 54,
249 96, 92, 93, 94, 95, 49, 78, 98, 69, 70,
250 71, 101, 102, 73, 74, 66, 64, 67, 55, 56,
251 57, 58, 59, 69, 85, 69, 0, 69, 0, 75,
252 76, 77, 87, 88, 0, 69, 69, 0, 0, 0,
253 0, 0, 0, 0, 0, 90, 0, 0, 86, 0,
254 0, 0, 69, 0, 0, 0, 0, 0, 0, 0,
255 0, 0, 1, 2, 3, 4, 5, 6, 7, 8,
256 9, 10, 11, 12, 99, 80, 13, 14, 15, 16,
257 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
258 24, 25, 26, 0, 27, 0, 0, 0, 81, 1,
259 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
260 12, 0, 0, 13, 14, 15, 16, 17, 18, 19,
261 20, 21, 22, 0, 0, 23, 0, 24, 25, 26,
262 0, 27, 0, 0, 0, 62, 1, 2, 3, 4,
263 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
264 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
265 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
266 0, 0, 81, 1, 2, 3, 4, 5, 6, 7,
267 8, 9, 10, 11, 12, 0, 0, 13, 14, 15,
268 16, 17, 18, 19, 20, 21, 22, 0, 0, 23,
269 0, 24, 25, 26, 0, 27, 0, 0, 0, 97,
270 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
271 11, 12, 0, 0, 13, 14, 15, 16, 17, 18,
272 19, 20, 21, 22, 0, 0, 23, 0, 24, 25,
273 26, 0, 27, 0, 0, 72, 1, 2, 3, 4,
274 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
275 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
276 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
277 0, 89, 1, 2, 3, 4, 5, 6, 7, 8,
278 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
279 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
280 24, 25, 26, 0, 27, 0, 60, 1, 2, 3,
281 4, 5, 6, 7, 8, 9, 10, 11, 12, 0,
282 0, 13, 14, 15, 16, 17, 18, 19, 20, 21,
283 22, 0, 0, 23, 0, 24, 25, 26, 0, 27,
284 0, 79, 1, 2, 3, 4, 5, 6, 7, 8,
285 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
286 17, 18, 19, 20, 21, 22, 82, 0, 23, 83,
287 24, 25, 26, 0, 27, 1, 2, 3, 4, 5,
288 6, 7, 8, 9, 10, 11, 12, 0, 0, 13,
289 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
290 0, 23, 0, 24, 25, 26, 0, 27, 2, 3,
291 4, 5, 6, 7, 8, 9, 10, 0, 0, 0,
292 0, 13, 14, 0, 16, 17, 18, 19, 0, 0,
293 0, 0, 0, 0, 0, 24, 25
296 static const short yycheck[] = { 11,
297 12, 26, 27, 34, 35, 30, 32, 28, 20, 21,
298 42, 37, 38, 39, 40, 35, 32, 32, 46, 41,
299 42, 0, 0, 48, 49, 37, 29, 39, 32, 33,
300 34, 35, 36, 61, 68, 63, -1, 65, -1, 51,
301 52, 53, 70, 71, -1, 73, 74, -1, -1, -1,
302 -1, -1, -1, -1, -1, 80, -1, -1, 70, -1,
303 -1, -1, 90, -1, -1, -1, -1, -1, -1, -1,
304 -1, -1, 3, 4, 5, 6, 7, 8, 9, 10,
305 11, 12, 13, 14, 96, 16, 17, 18, 19, 20,
306 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
307 31, 32, 33, -1, 35, -1, -1, -1, 39, 3,
308 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
309 14, -1, -1, 17, 18, 19, 20, 21, 22, 23,
310 24, 25, 26, -1, -1, 29, -1, 31, 32, 33,
311 -1, 35, -1, -1, -1, 39, 3, 4, 5, 6,
312 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
313 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
314 -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
315 -1, -1, 39, 3, 4, 5, 6, 7, 8, 9,
316 10, 11, 12, 13, 14, -1, -1, 17, 18, 19,
317 20, 21, 22, 23, 24, 25, 26, -1, -1, 29,
318 -1, 31, 32, 33, -1, 35, -1, -1, -1, 39,
319 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
320 13, 14, -1, -1, 17, 18, 19, 20, 21, 22,
321 23, 24, 25, 26, -1, -1, 29, -1, 31, 32,
322 33, -1, 35, -1, -1, 38, 3, 4, 5, 6,
323 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
324 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
325 -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
326 -1, 38, 3, 4, 5, 6, 7, 8, 9, 10,
327 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
328 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
329 31, 32, 33, -1, 35, -1, 37, 3, 4, 5,
330 6, 7, 8, 9, 10, 11, 12, 13, 14, -1,
331 -1, 17, 18, 19, 20, 21, 22, 23, 24, 25,
332 26, -1, -1, 29, -1, 31, 32, 33, -1, 35,
333 -1, 37, 3, 4, 5, 6, 7, 8, 9, 10,
334 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
335 21, 22, 23, 24, 25, 26, 27, -1, 29, 30,
336 31, 32, 33, -1, 35, 3, 4, 5, 6, 7,
337 8, 9, 10, 11, 12, 13, 14, -1, -1, 17,
338 18, 19, 20, 21, 22, 23, 24, 25, 26, -1,
339 -1, 29, -1, 31, 32, 33, -1, 35, 4, 5,
340 6, 7, 8, 9, 10, 11, 12, -1, -1, -1,
341 -1, 17, 18, -1, 20, 21, 22, 23, -1, -1,
342 -1, -1, -1, -1, -1, 31, 32
344 /* This file comes from bison-1.28. */
346 /* Skeleton output parser for bison,
347 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
349 This program is free software; you can redistribute it and/or modify
350 it under the terms of the GNU General Public License as published by
351 the Free Software Foundation; either version 2, or (at your option)
352 any later version.
354 This program is distributed in the hope that it will be useful,
355 but WITHOUT ANY WARRANTY; without even the implied warranty of
356 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
357 GNU General Public License for more details.
359 You should have received a copy of the GNU General Public License
360 along with this program; if not, write to the Free Software
361 Foundation, Inc., 59 Temple Place - Suite 330,
362 Boston, MA 02111-1307, USA. */
364 /* As a special exception, when this file is copied by Bison into a
365 Bison output file, you may use that output file without restriction.
366 This special exception was added by the Free Software Foundation
367 in version 1.24 of Bison. */
369 /* This is the parser code that is written into each bison parser
370 when the %semantic_parser declaration is not specified in the grammar.
371 It was written by Richard Stallman by simplifying the hairy parser
372 used when %semantic_parser is specified. */
374 #ifndef YYSTACK_USE_ALLOCA
375 #ifdef alloca
376 #define YYSTACK_USE_ALLOCA
377 #else /* alloca not defined */
378 #ifdef __GNUC__
379 #define YYSTACK_USE_ALLOCA
380 #define alloca __builtin_alloca
381 #else /* not GNU C. */
382 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
383 #define YYSTACK_USE_ALLOCA
384 #include <sal/alloca.h>
385 #else /* not sparc */
386 #if defined(_AIX)
387 #pragma alloca
388 #define YYSTACK_USE_ALLOCA
389 #endif /* not _AIX */
390 #endif /* not sparc */
391 #endif /* not GNU C */
392 #endif /* alloca not defined */
393 #endif /* YYSTACK_USE_ALLOCA not defined */
395 #ifdef YYSTACK_USE_ALLOCA
396 #define YYSTACK_ALLOC alloca
397 #else
398 #define YYSTACK_ALLOC malloc
399 #endif
401 /* Note: there must be only one dollar sign in this file.
402 It is replaced by the list of actions, each action
403 as one case of the switch. */
405 #define YYEMPTY -2
406 #define YYEOF 0
407 #define YYACCEPT goto yyacceptlab
408 #define YYABORT goto yyabortlab
410 #define YYTERROR 1
412 #ifndef YYPURE
413 #define YYLEX yylex()
414 #endif
416 #ifdef YYPURE
417 #ifdef YYLSP_NEEDED
418 #ifdef YYLEX_PARAM
419 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
420 #else
421 #define YYLEX yylex(&yylval, &yylloc)
422 #endif
423 #else /* not YYLSP_NEEDED */
424 #ifdef YYLEX_PARAM
425 #define YYLEX yylex(&yylval, YYLEX_PARAM)
426 #else
427 #define YYLEX yylex(&yylval)
428 #endif
429 #endif /* not YYLSP_NEEDED */
430 #endif
432 /* If nonreentrant, generate the variables here */
434 #ifndef YYPURE
436 int yychar; /* the lookahead symbol */
437 YYSTYPE yylval; /* the semantic value of the */
438 /* lookahead symbol */
440 #ifdef YYLSP_NEEDED
441 YYLTYPE yylloc; /* location data for the lookahead */
442 /* symbol */
443 #endif
445 int yynerrs; /* number of parse errors so far */
446 #endif /* not YYPURE */
448 #if YYDEBUG != 0
449 int yydebug; /* nonzero means print parse trace */
450 /* Since this is uninitialized, it does not stop multiple parsers
451 from coexisting. */
452 #endif
454 /* YYINITDEPTH indicates the initial size of the parser's stacks */
456 #ifndef YYINITDEPTH
457 #define YYINITDEPTH 200
458 #endif
460 /* YYMAXDEPTH is the maximum size the stacks can grow to
461 (effective only if the built-in stack extension method is used). */
463 #if YYMAXDEPTH == 0
464 #undef YYMAXDEPTH
465 #endif
467 #ifndef YYMAXDEPTH
468 #define YYMAXDEPTH 10000
469 #endif
471 /* Define __yy_memcpy. Note that the size argument
472 should be passed with type unsigned int, because that is what the non-GCC
473 definitions require. With GCC, __builtin_memcpy takes an arg
474 of type size_t, but it can handle unsigned int. */
476 #if defined(__GNUC__)
477 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
478 #else
479 #ifndef __cplusplus
481 /* This is the most reliable way to avoid incompatibilities
482 in available built-in functions on various systems. */
483 static void
484 __yy_memcpy (to, from, count)
485 char *to;
486 char *from;
487 unsigned int count;
489 register char *f = from;
490 register char *t = to;
491 register int i = count;
493 while (i-- > 0)
494 *t++ = *f++;
497 #else /* __cplusplus */
499 /* This is the most reliable way to avoid incompatibilities
500 in available built-in functions on various systems. */
501 static void
502 __yy_memcpy (char *to, char *from, unsigned int count)
504 register char *t = to;
505 register char *f = from;
506 register int i = count;
508 while (i-- > 0)
509 *t++ = *f++;
512 #endif
513 #endif
515 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
516 into yyparse. The argument should have type void *.
517 It should actually point to an object.
518 Grammar actions can access the variable by casting it
519 to the proper pointer type. */
521 #ifdef YYPARSE_PARAM
522 #ifdef __cplusplus
523 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
524 #define YYPARSE_PARAM_DECL
525 #else /* not __cplusplus */
526 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
527 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
528 #endif /* not __cplusplus */
529 #else /* not YYPARSE_PARAM */
530 #define YYPARSE_PARAM_ARG
531 #define YYPARSE_PARAM_DECL
532 #endif /* not YYPARSE_PARAM */
534 /* Prevent warning if -Wstrict-prototypes. */
535 #ifdef __GNUC__
536 #ifdef YYPARSE_PARAM
537 int yyparse (void *);
538 #else
539 int yyparse (void);
540 #endif
541 #endif
544 yyparse(YYPARSE_PARAM_ARG)
545 YYPARSE_PARAM_DECL
547 register int yystate;
548 register int yyn;
549 register short *yyssp;
550 register YYSTYPE *yyvsp;
551 int yyerrstatus; /* number of tokens to shift before error messages enabled */
552 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
554 short yyssa[YYINITDEPTH]; /* the state stack */
555 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
557 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
558 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
560 #ifdef YYLSP_NEEDED
561 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
562 YYLTYPE *yyls = yylsa;
563 YYLTYPE *yylsp;
565 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
566 #endif
568 int yystacksize = YYINITDEPTH;
569 int yyfree_stacks = 0;
571 #ifdef YYPURE
572 int yychar;
573 YYSTYPE yylval;
574 int yynerrs;
575 #ifdef YYLSP_NEEDED
576 YYLTYPE yylloc;
577 #endif
578 #endif
580 YYSTYPE yyval; /* the variable used to return */
581 yyval.dval = 0;
582 /* semantic values from the action */
583 /* routines */
585 int yylen;
587 #if YYDEBUG != 0
588 if (yydebug)
589 fprintf(stderr, "Starting parse\n");
590 #endif
592 yystate = 0;
593 yyerrstatus = 0;
594 yynerrs = 0;
595 yychar = YYEMPTY; /* Cause a token to be read. */
597 /* Initialize stack pointers.
598 Waste one element of value and location stack
599 so that they stay on the same level as the state stack.
600 The wasted elements are never initialized. */
602 yyssp = yyss - 1;
603 yyvsp = yyvs;
604 #ifdef YYLSP_NEEDED
605 yylsp = yyls;
606 #endif
608 /* Push a new state, which is found in yystate . */
609 /* In all cases, when you get here, the value and location stacks
610 have just been pushed. so pushing a state here evens the stacks. */
611 yynewstate:
613 *++yyssp = sal::static_int_cast<short>(yystate);
615 if (yyssp >= yyss + yystacksize - 1)
617 /* Give user a chance to reallocate the stack */
618 /* Use copies of these so that the &'s don't force the real ones into memory. */
619 YYSTYPE *yyvs1 = yyvs;
620 short *yyss1 = yyss;
621 #ifdef YYLSP_NEEDED
622 YYLTYPE *yyls1 = yyls;
623 #endif
625 /* Get the current used size of the three stacks, in elements. */
626 int size = yyssp - yyss + 1;
628 #ifdef yyoverflow
629 /* Each stack pointer address is followed by the size of
630 the data in use in that stack, in bytes. */
631 #ifdef YYLSP_NEEDED
632 /* This used to be a conditional around just the two extra args,
633 but that might be undefined if yyoverflow is a macro. */
634 yyoverflow("parser stack overflow",
635 &yyss1, size * sizeof (*yyssp),
636 &yyvs1, size * sizeof (*yyvsp),
637 &yyls1, size * sizeof (*yylsp),
638 &yystacksize);
639 #else
640 yyoverflow("parser stack overflow",
641 &yyss1, size * sizeof (*yyssp),
642 &yyvs1, size * sizeof (*yyvsp),
643 &yystacksize);
644 #endif
646 yyss = yyss1; yyvs = yyvs1;
647 #ifdef YYLSP_NEEDED
648 yyls = yyls1;
649 #endif
650 #else /* no yyoverflow */
651 /* Extend the stack our own way. */
652 if (yystacksize >= YYMAXDEPTH)
654 yyerror("parser stack overflow");
655 if (yyfree_stacks)
657 free (yyss);
658 free (yyvs);
659 #ifdef YYLSP_NEEDED
660 free (yyls);
661 #endif
663 return 2;
665 yystacksize *= 2;
666 if (yystacksize > YYMAXDEPTH)
667 yystacksize = YYMAXDEPTH;
668 #ifndef YYSTACK_USE_ALLOCA
669 yyfree_stacks = 1;
670 #endif
671 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
672 __yy_memcpy ((char *)yyss, (char *)yyss1,
673 size * (unsigned int) sizeof (*yyssp));
674 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
675 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
676 size * (unsigned int) sizeof (*yyvsp));
677 #ifdef YYLSP_NEEDED
678 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
679 __yy_memcpy ((char *)yyls, (char *)yyls1,
680 size * (unsigned int) sizeof (*yylsp));
681 #endif
682 #endif /* no yyoverflow */
684 yyssp = yyss + size - 1;
685 yyvsp = yyvs + size - 1;
686 #ifdef YYLSP_NEEDED
687 yylsp = yyls + size - 1;
688 #endif
690 #if YYDEBUG != 0
691 if (yydebug)
692 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
693 #endif
695 if (yyssp >= yyss + yystacksize - 1)
696 YYABORT;
699 #if YYDEBUG != 0
700 if (yydebug)
701 fprintf(stderr, "Entering state %d\n", yystate);
702 #endif
704 goto yybackup;
705 yybackup:
707 /* Do appropriate processing given the current state. */
708 /* Read a lookahead token if we need one and don't already have one. */
709 /* yyresume: */
711 /* First try to decide what to do without reference to lookahead token. */
713 yyn = yypact[yystate];
714 if (yyn == YYFLAG)
715 goto yydefault;
717 /* Not known => get a lookahead token if don't already have one. */
719 /* yychar is either YYEMPTY or YYEOF
720 or a valid token in external form. */
722 if (yychar == YYEMPTY)
724 #if YYDEBUG != 0
725 if (yydebug)
726 fprintf(stderr, "Reading a token: ");
727 #endif
728 yychar = YYLEX;
731 /* Convert token to internal form (in yychar1) for indexing tables with */
733 if (yychar <= 0) /* This means end of input. */
735 yychar1 = 0;
736 yychar = YYEOF; /* Don't call YYLEX any more */
738 #if YYDEBUG != 0
739 if (yydebug)
740 fprintf(stderr, "Now at end of input.\n");
741 #endif
743 else
745 yychar1 = YYTRANSLATE(yychar);
747 #if YYDEBUG != 0
748 if (yydebug)
750 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
751 /* Give the individual parser a way to print the precise meaning
752 of a token, for further debugging info. */
753 #ifdef YYPRINT
754 YYPRINT (stderr, yychar, yylval);
755 #endif
756 fprintf (stderr, ")\n");
758 #endif
761 yyn += yychar1;
762 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
763 goto yydefault;
765 yyn = yytable[yyn];
767 /* yyn is what to do for this token type in this state.
768 Negative => reduce, -yyn is rule number.
769 Positive => shift, yyn is new state.
770 New state is final state => don't bother to shift,
771 just return success.
772 0, or most negative number => error. */
774 if (yyn < 0)
776 if (yyn == YYFLAG)
777 goto yyerrlab;
778 yyn = -yyn;
779 goto yyreduce;
781 else if (yyn == 0)
782 goto yyerrlab;
784 if (yyn == YYFINAL)
785 YYACCEPT;
787 /* Shift the lookahead token. */
789 #if YYDEBUG != 0
790 if (yydebug)
791 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
792 #endif
794 /* Discard the token being shifted unless it is eof. */
795 if (yychar != YYEOF)
796 yychar = YYEMPTY;
798 *++yyvsp = yylval;
799 #ifdef YYLSP_NEEDED
800 *++yylsp = yylloc;
801 #endif
803 /* count tokens shifted since error; after three, turn off error status. */
804 if (yyerrstatus) yyerrstatus--;
806 yystate = yyn;
807 goto yynewstate;
809 /* Do the default action for the current state. */
810 yydefault:
812 yyn = yydefact[yystate];
813 if (yyn == 0)
814 goto yyerrlab;
816 /* Do a reduction. yyn is the number of a rule to reduce with. */
817 yyreduce:
818 yylen = yyr2[yyn];
819 if (yylen > 0)
820 yyval = yyvsp[1-yylen]; /* implement default value of the action */
822 #if YYDEBUG != 0
823 if (yydebug)
825 int i;
827 fprintf (stderr, "Reducing via rule %d (line %d), ",
828 yyn, yyrline[yyn]);
830 /* Print the symbols being reduced, and their result. */
831 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
832 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
833 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
835 #endif
838 switch (yyn) {
840 case 1:
841 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
842 break;}
843 case 2:
844 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
845 break;}
846 case 3:
847 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
848 break;}
849 case 4:
850 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
851 break;}
852 case 5:
853 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
854 break;}
855 case 6:
856 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
857 break;}
858 case 7:
859 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
860 break;}
861 case 8:
862 { yyval.ptr = new Node(ID_CHARACTER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
863 break;}
864 case 9:
865 { yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
866 break;}
867 case 10:
868 { yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
869 break;}
870 case 11:
871 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
872 break;}
873 case 12:
874 { yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
875 break;}
876 case 13:
877 { yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
878 break;}
879 case 14:
880 { yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
881 break;}
882 case 15:
883 { yyval.ptr = new Node(ID_CHARACTER); allocChar(yyval.ptr->value , '|'); debug("Identifier : '|'\n"); nodelist.push_back(yyval.ptr); ;
884 break;}
885 case 16:
886 { yyval.ptr = new Node(ID_NUMBER); allocValue(yyval.ptr->value , yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.push_back(yyval.ptr); ;
887 break;}
888 case 17:
889 { yyval.ptr = new Node(ID_STRING); allocValue(yyval.ptr->value , yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
890 break;}
891 case 18:
892 { yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.push_back(yyval.ptr); ;
893 break;}
894 case 19:
895 { yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyval.ptr->next = yyvsp[0].ptr; debug("PrimaryExpr : PrimaryExpr Identifier\n"); nodelist.push_back(yyval.ptr); ;
896 break;}
897 case 20:
898 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '('); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
899 break;}
900 case 21:
901 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '['); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
902 break;}
903 case 22:
904 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '{'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
905 break;}
906 case 23:
907 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '<'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
908 break;}
909 case 24:
910 { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '|'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
911 break;}
912 case 25:
913 { yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , "||"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
914 break;}
915 case 26:
916 { yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
917 break;}
918 case 27:
919 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ')'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
920 break;}
921 case 28:
922 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ']'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
923 break;}
924 case 29:
925 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '}'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
926 break;}
927 case 30:
928 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '>'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
929 break;}
930 case 31:
931 { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '|'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
932 break;}
933 case 32:
934 { yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , "||"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
935 break;}
936 case 33:
937 { yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
938 break;}
939 case 34:
940 { 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.push_back(yyval.ptr); ;
941 break;}
942 case 35:
943 { yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.push_back(yyval.ptr); ;
944 break;}
945 case 36:
946 { yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.push_back(yyval.ptr); ;
947 break;}
948 case 37:
949 { yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.push_back(yyval.ptr); ;
950 break;}
951 case 38:
952 { yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.push_back(yyval.ptr); ;
953 break;}
954 case 39:
955 { yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.push_back(yyval.ptr); ;
956 break;}
957 case 40:
958 { yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.push_back(yyval.ptr); ;
959 break;}
960 case 41:
961 { 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.push_back(yyval.ptr); ;
962 break;}
963 case 42:
964 { 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.push_back(yyval.ptr); ;
965 break;}
966 case 43:
967 { 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.push_back(yyval.ptr); ;
968 break;}
969 case 44:
970 { 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.push_back(yyval.ptr); ;
971 break;}
972 case 45:
973 { yyval.ptr = new Node(ID_OVER); yyval.ptr->child = yyvsp[-3].ptr; yyvsp[-3].ptr->next = yyvsp[-1].ptr; debug("OverExpr\n"); nodelist.push_back(yyval.ptr); ;
974 break;}
975 case 46:
976 { yyval.ptr = new Node(ID_ACCENTEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
977 break;}
978 case 47:
979 { yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->child=yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("AccentExpr \n"); nodelist.push_back(yyval.ptr); ;
980 break;}
981 case 48:
982 { yyval.ptr = new Node(ID_DECORATIONEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
983 break;}
984 case 49:
985 { yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("DecorationExpr \n"); nodelist.push_back(yyval.ptr); ;
986 break;}
987 case 50:
988 { yyval.ptr = new Node(ID_SQRTEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-1].str); nodelist.push_back(yyval.ptr); ;
989 break;}
990 case 51:
991 { 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.push_back(yyval.ptr); ;
992 break;}
993 case 52:
994 { yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("BeginExpr\n"); ;
995 break;}
996 case 53:
997 { yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("BeginExpr\n"); ;
998 break;}
999 case 54:
1000 { yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("EndExpr\n"); ;
1001 break;}
1002 case 55:
1003 { yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); top = yyval.ptr; debug("MathML\n"); ;
1004 break;}
1005 case 56:
1006 { yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("Lines\n"); ;
1007 break;}
1008 case 57:
1009 { yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("Lines\n"); ;
1010 break;}
1011 case 58:
1012 { yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("Line\n"); ;
1013 break;}
1014 case 59:
1015 { yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.push_back(yyval.ptr); ;
1016 break;}
1017 case 60:
1018 { 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.push_back(yyval.ptr); ;
1019 break;}
1020 case 61:
1021 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.push_back(yyval.ptr);;
1022 break;}
1023 case 62:
1024 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.push_back(yyval.ptr);;
1025 break;}
1026 case 63:
1027 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.push_back(yyval.ptr);;
1028 break;}
1029 case 64:
1030 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.push_back(yyval.ptr);;
1031 break;}
1032 case 65:
1033 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.push_back(yyval.ptr);;
1034 break;}
1035 case 66:
1036 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.push_back(yyval.ptr);;
1037 break;}
1038 case 67:
1039 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.push_back(yyval.ptr);;
1040 break;}
1041 case 68:
1042 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.push_back(yyval.ptr);;
1043 break;}
1044 case 69:
1045 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.push_back(yyval.ptr);;
1046 break;}
1047 case 70:
1048 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.push_back(yyval.ptr);;
1049 break;}
1050 case 71:
1051 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.push_back(yyval.ptr);;
1052 break;}
1053 case 72:
1054 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.push_back(yyval.ptr);;
1055 break;}
1057 /* the action file gets copied in in place of this dollarsign */
1059 yyvsp -= yylen;
1060 yyssp -= yylen;
1061 #ifdef YYLSP_NEEDED
1062 yylsp -= yylen;
1063 #endif
1065 #if YYDEBUG != 0
1066 if (yydebug)
1068 short *ssp1 = yyss - 1;
1069 fprintf (stderr, "state stack now");
1070 while (ssp1 != yyssp)
1071 fprintf (stderr, " %d", *++ssp1);
1072 fprintf (stderr, "\n");
1074 #endif
1076 *++yyvsp = yyval;
1078 #ifdef YYLSP_NEEDED
1079 yylsp++;
1080 if (yylen == 0)
1082 yylsp->first_line = yylloc.first_line;
1083 yylsp->first_column = yylloc.first_column;
1084 yylsp->last_line = (yylsp-1)->last_line;
1085 yylsp->last_column = (yylsp-1)->last_column;
1086 yylsp->text = 0;
1088 else
1090 yylsp->last_line = (yylsp+yylen-1)->last_line;
1091 yylsp->last_column = (yylsp+yylen-1)->last_column;
1093 #endif
1095 /* Now "shift" the result of the reduction.
1096 Determine what state that goes to,
1097 based on the state we popped back to
1098 and the rule number reduced by. */
1100 yyn = yyr1[yyn];
1102 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1103 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1104 yystate = yytable[yystate];
1105 else
1106 yystate = yydefgoto[yyn - YYNTBASE];
1108 goto yynewstate;
1110 yyerrlab: /* here on detecting error */
1112 if (! yyerrstatus)
1113 /* If not already recovering from an error, report this error. */
1115 ++yynerrs;
1117 #ifdef YYERROR_VERBOSE
1118 yyn = yypact[yystate];
1120 if (yyn > YYFLAG && yyn < YYLAST)
1122 int size = 0;
1123 char *msg;
1124 int x, count;
1126 count = 0;
1127 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1128 for (x = (yyn < 0 ? -yyn : 0);
1129 x < (sizeof(yytname) / sizeof(char *)); x++)
1130 if (yycheck[x + yyn] == x)
1131 size += strlen(yytname[x]) + 15, count++;
1132 msg = (char *) malloc(size + 15);
1133 if (msg != 0)
1135 strcpy(msg, "parse error");
1137 if (count < 5)
1139 count = 0;
1140 for (x = (yyn < 0 ? -yyn : 0);
1141 x < (sizeof(yytname) / sizeof(char *)); x++)
1142 if (yycheck[x + yyn] == x)
1144 strcat(msg, count == 0 ? ", expecting `" : " or `");
1145 strcat(msg, yytname[x]);
1146 strcat(msg, "'");
1147 count++;
1150 yyerror(msg);
1151 free(msg);
1153 else
1154 yyerror ("parse error; also virtual memory exceeded");
1156 else
1157 #endif /* YYERROR_VERBOSE */
1158 yyerror("parse error");
1161 goto yyerrlab1;
1162 yyerrlab1: /* here on error raised explicitly by an action */
1164 if (yyerrstatus == 3)
1166 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1168 /* return failure if at end of input */
1169 if (yychar == YYEOF)
1170 YYABORT;
1172 #if YYDEBUG != 0
1173 if (yydebug)
1174 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1175 #endif
1177 yychar = YYEMPTY;
1180 /* Else will try to reuse lookahead token
1181 after shifting the error token. */
1183 yyerrstatus = 3; /* Each real token shifted decrements this */
1185 goto yyerrhandle;
1187 yyerrdefault: /* current state does not do anything special for the error token. */
1189 #if 0
1190 /* This is wrong; only states that explicitly want error tokens
1191 should shift them. */
1192 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1193 if (yyn) goto yydefault;
1194 #endif
1196 yyerrpop: /* pop the current state because it cannot handle the error token */
1198 if (yyssp == yyss) YYABORT;
1199 yyvsp--;
1200 yystate = *--yyssp;
1201 #ifdef YYLSP_NEEDED
1202 yylsp--;
1203 #endif
1205 #if YYDEBUG != 0
1206 if (yydebug)
1208 short *ssp1 = yyss - 1;
1209 fprintf (stderr, "Error: state stack now");
1210 while (ssp1 != yyssp)
1211 fprintf (stderr, " %d", *++ssp1);
1212 fprintf (stderr, "\n");
1214 #endif
1216 yyerrhandle:
1218 yyn = yypact[yystate];
1219 if (yyn == YYFLAG)
1220 goto yyerrdefault;
1222 yyn += YYTERROR;
1223 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1224 goto yyerrdefault;
1226 yyn = yytable[yyn];
1227 if (yyn < 0)
1229 if (yyn == YYFLAG)
1230 goto yyerrpop;
1231 yyn = -yyn;
1232 goto yyreduce;
1234 else if (yyn == 0)
1235 goto yyerrpop;
1237 if (yyn == YYFINAL)
1238 YYACCEPT;
1240 #if YYDEBUG != 0
1241 if (yydebug)
1242 fprintf(stderr, "Shifting error token, ");
1243 #endif
1245 *++yyvsp = yylval;
1246 #ifdef YYLSP_NEEDED
1247 *++yylsp = yylloc;
1248 #endif
1250 yystate = yyn;
1251 goto yynewstate;
1253 yyacceptlab:
1254 /* YYACCEPT comes here. */
1255 if (yyfree_stacks)
1257 free (yyss);
1258 free (yyvs);
1259 #ifdef YYLSP_NEEDED
1260 free (yyls);
1261 #endif
1263 return 0;
1265 yyabortlab:
1266 /* YYABORT comes here. */
1267 if (yyfree_stacks)
1269 free (yyss);
1270 free (yyvs);
1271 #ifdef YYLSP_NEEDED
1272 free (yyls);
1273 #endif
1275 return 1;
1279 Node *mainParse(const char *_code)
1281 initFlex( _code );
1282 top = 0L;
1283 yyparse();
1284 if( top )
1285 return top;
1286 else
1287 return 0L;
1290 void yyerror(const char * /*err*/)
1292 // printf("REALKING ERR[%s]\n",err);
1293 // if error, delete all nodes.
1294 Node *pNode = 0L;
1295 int ncount = nodelist.size();
1296 for( int i = 0 ; i < ncount ; i++){
1297 pNode = nodelist.front();
1298 nodelist.pop_front();
1299 delete pNode;
1301 top = 0L;
1304 #ifndef PARSE_DEBUG
1305 int debug(const char * /*format*/, ...)
1307 return 0;
1309 #endif
1311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */