Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : /* A Bison parser, made from grammar.y
22 : by GNU Bison version 1.28 */
23 :
24 : #ifndef YYDEBUG
25 : #define YYDEBUG 0
26 : #endif
27 : #ifndef YYMAXDEPTH
28 : #define YYMAXDEPTH 0
29 : #endif
30 :
31 : #include <list>
32 : #include <stdlib.h>
33 : #include <string.h>
34 :
35 : #include "nodes.h"
36 :
37 0 : std::list<Node*> nodelist;
38 :
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);
44 :
45 : Node *top=0L;
46 :
47 : int Node::count = 0;
48 :
49 : #define allocValue(x,y) \
50 : x = (char *)malloc( strlen(y) +1 ); \
51 : strcpy(x,y)
52 :
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
61 :
62 :
63 : typedef union {
64 : char *dval;
65 : char *str;
66 : Node *ptr;
67 : } YYSTYPE;
68 : #include <stdio.h>
69 :
70 : #ifndef __cplusplus
71 : #ifndef __STDC__
72 : #define const
73 : #endif
74 : #endif
75 :
76 :
77 :
78 : #define YYFINAL 102
79 : #define YYFLAG -32768
80 : #define YYNTBASE 43
81 :
82 : #define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66)
83 :
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
114 : };
115 :
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
126 : };
127 :
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
149 : };
150 :
151 : #endif
152 :
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
163 : };
164 : #endif
165 :
166 :
167 : #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
168 :
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
178 : };
179 : #endif
180 :
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
190 : };
191 :
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
201 : };
202 :
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
215 : };
216 :
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
221 : };
222 :
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
235 : };
236 :
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
241 : };
242 :
243 :
244 : #define YYLAST 457
245 :
246 :
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
294 : };
295 :
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
343 : };
344 : /* This file comes from bison-1.28. */
345 :
346 : /* Skeleton output parser for bison,
347 : Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
348 :
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.
353 :
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.
358 :
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. */
363 :
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. */
368 :
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. */
373 :
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 (__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 */
394 :
395 : #ifdef YYSTACK_USE_ALLOCA
396 : #define YYSTACK_ALLOC alloca
397 : #else
398 : #define YYSTACK_ALLOC malloc
399 : #endif
400 :
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. */
404 :
405 : #define YYEMPTY -2
406 : #define YYEOF 0
407 : #define YYACCEPT goto yyacceptlab
408 : #define YYABORT goto yyabortlab
409 :
410 : #define YYTERROR 1
411 :
412 : #ifndef YYPURE
413 : #define YYLEX yylex()
414 : #endif
415 :
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
431 :
432 : /* If nonreentrant, generate the variables here */
433 :
434 : #ifndef YYPURE
435 :
436 : int yychar; /* the lookahead symbol */
437 : YYSTYPE yylval; /* the semantic value of the */
438 : /* lookahead symbol */
439 :
440 : #ifdef YYLSP_NEEDED
441 : YYLTYPE yylloc; /* location data for the lookahead */
442 : /* symbol */
443 : #endif
444 :
445 : int yynerrs; /* number of parse errors so far */
446 : #endif /* not YYPURE */
447 :
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
453 :
454 : /* YYINITDEPTH indicates the initial size of the parser's stacks */
455 :
456 : #ifndef YYINITDEPTH
457 : #define YYINITDEPTH 200
458 : #endif
459 :
460 : /* YYMAXDEPTH is the maximum size the stacks can grow to
461 : (effective only if the built-in stack extension method is used). */
462 :
463 : #if YYMAXDEPTH == 0
464 : #undef YYMAXDEPTH
465 : #endif
466 :
467 : #ifndef YYMAXDEPTH
468 : #define YYMAXDEPTH 10000
469 : #endif
470 :
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. */
475 :
476 : #if defined(__GNUC__)
477 : #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
478 : #else
479 : #ifndef __cplusplus
480 :
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;
488 : {
489 : char *f = from;
490 : char *t = to;
491 : int i = count;
492 :
493 : while (i-- > 0)
494 : *t++ = *f++;
495 : }
496 :
497 : #else /* __cplusplus */
498 :
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)
503 : {
504 : char *t = to;
505 : char *f = from;
506 : int i = count;
507 :
508 : while (i-- > 0)
509 : *t++ = *f++;
510 : }
511 :
512 : #endif
513 : #endif
514 :
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. */
520 :
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 */
533 :
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
542 :
543 : int
544 0 : yyparse(YYPARSE_PARAM_ARG)
545 : YYPARSE_PARAM_DECL
546 : {
547 : int yystate;
548 : int yyn;
549 : short *yyssp;
550 : YYSTYPE *yyvsp;
551 : int yyerrstatus; /* number of tokens to shift before error messages enabled */
552 0 : int yychar1 = 0; /* lookahead token as an internal (translated) token number */
553 :
554 : short yyssa[YYINITDEPTH]; /* the state stack */
555 : YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
556 :
557 0 : short *yyss = yyssa; /* refer to the stacks thru separate pointers */
558 0 : YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
559 :
560 : #ifdef YYLSP_NEEDED
561 : YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
562 : YYLTYPE *yyls = yylsa;
563 : YYLTYPE *yylsp;
564 :
565 : #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
566 : #endif
567 :
568 0 : int yystacksize = YYINITDEPTH;
569 0 : int yyfree_stacks = 0;
570 :
571 : #ifdef YYPURE
572 : int yychar;
573 : YYSTYPE yylval;
574 : int yynerrs;
575 : #ifdef YYLSP_NEEDED
576 : YYLTYPE yylloc;
577 : #endif
578 : #endif
579 :
580 : YYSTYPE yyval; /* the variable used to return */
581 0 : yyval.dval = 0;
582 : /* semantic values from the action */
583 : /* routines */
584 :
585 : int yylen;
586 :
587 : #if YYDEBUG != 0
588 : if (yydebug)
589 : fprintf(stderr, "Starting parse\n");
590 : #endif
591 :
592 0 : yystate = 0;
593 0 : yyerrstatus = 0;
594 0 : yynerrs = 0;
595 0 : yychar = YYEMPTY; /* Cause a token to be read. */
596 :
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. */
601 :
602 0 : yyssp = yyss - 1;
603 0 : yyvsp = yyvs;
604 : #ifdef YYLSP_NEEDED
605 : yylsp = yyls;
606 : #endif
607 :
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:
612 :
613 0 : *++yyssp = sal::static_int_cast<short>(yystate);
614 :
615 0 : if (yyssp >= yyss + yystacksize - 1)
616 : {
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 0 : YYSTYPE *yyvs1 = yyvs;
620 0 : short *yyss1 = yyss;
621 : #ifdef YYLSP_NEEDED
622 : YYLTYPE *yyls1 = yyls;
623 : #endif
624 :
625 : /* Get the current used size of the three stacks, in elements. */
626 0 : int size = yyssp - yyss + 1;
627 :
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
645 :
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 0 : if (yystacksize >= YYMAXDEPTH)
653 : {
654 0 : yyerror("parser stack overflow");
655 0 : if (yyfree_stacks)
656 : {
657 0 : free (yyss);
658 0 : free (yyvs);
659 : #ifdef YYLSP_NEEDED
660 : free (yyls);
661 : #endif
662 : }
663 0 : return 2;
664 : }
665 0 : yystacksize *= 2;
666 0 : if (yystacksize > YYMAXDEPTH)
667 0 : yystacksize = YYMAXDEPTH;
668 : #ifndef YYSTACK_USE_ALLOCA
669 : yyfree_stacks = 1;
670 : #endif
671 0 : yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
672 0 : __yy_memcpy ((char *)yyss, (char *)yyss1,
673 0 : size * (unsigned int) sizeof (*yyssp));
674 0 : yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
675 0 : __yy_memcpy ((char *)yyvs, (char *)yyvs1,
676 0 : 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 */
683 :
684 0 : yyssp = yyss + size - 1;
685 0 : yyvsp = yyvs + size - 1;
686 : #ifdef YYLSP_NEEDED
687 : yylsp = yyls + size - 1;
688 : #endif
689 :
690 : #if YYDEBUG != 0
691 : if (yydebug)
692 : fprintf(stderr, "Stack size increased to %d\n", yystacksize);
693 : #endif
694 :
695 0 : if (yyssp >= yyss + yystacksize - 1)
696 0 : YYABORT;
697 : }
698 :
699 : #if YYDEBUG != 0
700 : if (yydebug)
701 : fprintf(stderr, "Entering state %d\n", yystate);
702 : #endif
703 :
704 0 : goto yybackup;
705 : yybackup:
706 :
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: */
710 :
711 : /* First try to decide what to do without reference to lookahead token. */
712 :
713 0 : yyn = yypact[yystate];
714 0 : if (yyn == YYFLAG)
715 0 : goto yydefault;
716 :
717 : /* Not known => get a lookahead token if don't already have one. */
718 :
719 : /* yychar is either YYEMPTY or YYEOF
720 : or a valid token in external form. */
721 :
722 0 : if (yychar == YYEMPTY)
723 : {
724 : #if YYDEBUG != 0
725 : if (yydebug)
726 : fprintf(stderr, "Reading a token: ");
727 : #endif
728 0 : yychar = YYLEX;
729 : }
730 :
731 : /* Convert token to internal form (in yychar1) for indexing tables with */
732 :
733 0 : if (yychar <= 0) /* This means end of input. */
734 : {
735 0 : yychar1 = 0;
736 0 : yychar = YYEOF; /* Don't call YYLEX any more */
737 :
738 : #if YYDEBUG != 0
739 : if (yydebug)
740 : fprintf(stderr, "Now at end of input.\n");
741 : #endif
742 : }
743 : else
744 : {
745 0 : yychar1 = YYTRANSLATE(yychar);
746 :
747 : #if YYDEBUG != 0
748 : if (yydebug)
749 : {
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");
757 : }
758 : #endif
759 : }
760 :
761 0 : yyn += yychar1;
762 0 : if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
763 : goto yydefault;
764 :
765 0 : yyn = yytable[yyn];
766 :
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. */
773 :
774 0 : if (yyn < 0)
775 : {
776 0 : if (yyn == YYFLAG)
777 0 : goto yyerrlab;
778 0 : yyn = -yyn;
779 0 : goto yyreduce;
780 : }
781 0 : else if (yyn == 0)
782 0 : goto yyerrlab;
783 :
784 0 : if (yyn == YYFINAL)
785 0 : YYACCEPT;
786 :
787 : /* Shift the lookahead token. */
788 :
789 : #if YYDEBUG != 0
790 : if (yydebug)
791 : fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
792 : #endif
793 :
794 : /* Discard the token being shifted unless it is eof. */
795 0 : if (yychar != YYEOF)
796 0 : yychar = YYEMPTY;
797 :
798 0 : *++yyvsp = yylval;
799 : #ifdef YYLSP_NEEDED
800 : *++yylsp = yylloc;
801 : #endif
802 :
803 : /* count tokens shifted since error; after three, turn off error status. */
804 0 : if (yyerrstatus) yyerrstatus--;
805 :
806 0 : yystate = yyn;
807 0 : goto yynewstate;
808 :
809 : /* Do the default action for the current state. */
810 : yydefault:
811 :
812 0 : yyn = yydefact[yystate];
813 0 : if (yyn == 0)
814 0 : goto yyerrlab;
815 :
816 : /* Do a reduction. yyn is the number of a rule to reduce with. */
817 : yyreduce:
818 0 : yylen = yyr2[yyn];
819 0 : if (yylen > 0)
820 0 : yyval = yyvsp[1-yylen]; /* implement default value of the action */
821 :
822 : #if YYDEBUG != 0
823 : if (yydebug)
824 : {
825 : int i;
826 :
827 : fprintf (stderr, "Reducing via rule %d (line %d), ",
828 : yyn, yyrline[yyn]);
829 :
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]]);
834 : }
835 : #endif
836 :
837 :
838 0 : switch (yyn) {
839 :
840 : case 1:
841 0 : { 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 0 : break;}
843 : case 2:
844 0 : { 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 0 : break;}
846 : case 3:
847 0 : { 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 0 : break;}
849 : case 4:
850 0 : { 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 0 : break;}
852 : case 5:
853 0 : { 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 0 : break;}
855 : case 6:
856 0 : { 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 0 : break;}
858 : case 7:
859 0 : { 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 0 : break;}
861 : case 8:
862 0 : { 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 0 : break;}
864 : case 9:
865 0 : { 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 0 : break;}
867 : case 10:
868 0 : { 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 0 : break;}
870 : case 11:
871 0 : { 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 0 : break;}
873 : case 12:
874 0 : { 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 0 : break;}
876 : case 13:
877 0 : { 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 0 : break;}
879 : case 14:
880 0 : { 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 0 : break;}
882 : case 15:
883 0 : { yyval.ptr = new Node(ID_CHARACTER); allocChar(yyval.ptr->value , '|'); debug("Identifier : '|'\n"); nodelist.push_back(yyval.ptr); ;
884 0 : break;}
885 : case 16:
886 0 : { 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 0 : break;}
888 : case 17:
889 0 : { 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 0 : break;}
891 : case 18:
892 0 : { yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.push_back(yyval.ptr); ;
893 0 : break;}
894 : case 19:
895 0 : { 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 0 : break;}
897 : case 20:
898 0 : { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '('); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
899 0 : break;}
900 : case 21:
901 0 : { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '['); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
902 0 : break;}
903 : case 22:
904 0 : { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '{'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
905 0 : break;}
906 : case 23:
907 0 : { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '<'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
908 0 : break;}
909 : case 24:
910 0 : { yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '|'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
911 0 : break;}
912 : case 25:
913 0 : { yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , "||"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
914 0 : break;}
915 : case 26:
916 0 : { yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
917 0 : break;}
918 : case 27:
919 0 : { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ')'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
920 0 : break;}
921 : case 28:
922 0 : { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ']'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
923 0 : break;}
924 : case 29:
925 0 : { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '}'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
926 0 : break;}
927 : case 30:
928 0 : { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '>'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
929 0 : break;}
930 : case 31:
931 0 : { yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '|'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
932 0 : break;}
933 : case 32:
934 0 : { yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , "||"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
935 0 : break;}
936 : case 33:
937 0 : { yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
938 0 : break;}
939 : case 34:
940 0 : { 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 0 : break;}
942 : case 35:
943 0 : { yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.push_back(yyval.ptr); ;
944 0 : break;}
945 : case 36:
946 0 : { yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.push_back(yyval.ptr); ;
947 0 : break;}
948 : case 37:
949 0 : { yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.push_back(yyval.ptr); ;
950 0 : break;}
951 : case 38:
952 0 : { yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.push_back(yyval.ptr); ;
953 0 : break;}
954 : case 39:
955 0 : { yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.push_back(yyval.ptr); ;
956 0 : break;}
957 : case 40:
958 0 : { yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.push_back(yyval.ptr); ;
959 0 : break;}
960 : case 41:
961 0 : { 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 0 : break;}
963 : case 42:
964 0 : { 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 0 : break;}
966 : case 43:
967 0 : { 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 0 : break;}
969 : case 44:
970 0 : { 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 0 : break;}
972 : case 45:
973 0 : { 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 0 : break;}
975 : case 46:
976 0 : { 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 0 : break;}
978 : case 47:
979 0 : { 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 0 : break;}
981 : case 48:
982 0 : { 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 0 : break;}
984 : case 49:
985 0 : { 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 0 : break;}
987 : case 50:
988 0 : { 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 0 : break;}
990 : case 51:
991 0 : { 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 0 : break;}
993 : case 52:
994 0 : { yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("BeginExpr\n"); ;
995 0 : break;}
996 : case 53:
997 0 : { 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 0 : break;}
999 : case 54:
1000 0 : { yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("EndExpr\n"); ;
1001 0 : break;}
1002 : case 55:
1003 0 : { yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); top = yyval.ptr; debug("MathML\n"); ;
1004 0 : break;}
1005 : case 56:
1006 0 : { yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("Lines\n"); ;
1007 0 : break;}
1008 : case 57:
1009 0 : { 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 0 : break;}
1011 : case 58:
1012 0 : { yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("Line\n"); ;
1013 0 : break;}
1014 : case 59:
1015 0 : { yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.push_back(yyval.ptr); ;
1016 0 : break;}
1017 : case 60:
1018 0 : { 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 0 : break;}
1020 : case 61:
1021 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.push_back(yyval.ptr);;
1022 0 : break;}
1023 : case 62:
1024 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.push_back(yyval.ptr);;
1025 0 : break;}
1026 : case 63:
1027 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.push_back(yyval.ptr);;
1028 0 : break;}
1029 : case 64:
1030 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.push_back(yyval.ptr);;
1031 0 : break;}
1032 : case 65:
1033 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.push_back(yyval.ptr);;
1034 0 : break;}
1035 : case 66:
1036 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.push_back(yyval.ptr);;
1037 0 : break;}
1038 : case 67:
1039 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.push_back(yyval.ptr);;
1040 0 : break;}
1041 : case 68:
1042 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.push_back(yyval.ptr);;
1043 0 : break;}
1044 : case 69:
1045 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.push_back(yyval.ptr);;
1046 0 : break;}
1047 : case 70:
1048 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.push_back(yyval.ptr);;
1049 0 : break;}
1050 : case 71:
1051 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.push_back(yyval.ptr);;
1052 0 : break;}
1053 : case 72:
1054 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.push_back(yyval.ptr);;
1055 0 : break;}
1056 : }
1057 : /* the action file gets copied in in place of this dollarsign */
1058 :
1059 0 : yyvsp -= yylen;
1060 0 : yyssp -= yylen;
1061 : #ifdef YYLSP_NEEDED
1062 : yylsp -= yylen;
1063 : #endif
1064 :
1065 : #if YYDEBUG != 0
1066 : if (yydebug)
1067 : {
1068 : short *ssp1 = yyss - 1;
1069 : fprintf (stderr, "state stack now");
1070 : while (ssp1 != yyssp)
1071 : fprintf (stderr, " %d", *++ssp1);
1072 : fprintf (stderr, "\n");
1073 : }
1074 : #endif
1075 :
1076 0 : *++yyvsp = yyval;
1077 :
1078 : #ifdef YYLSP_NEEDED
1079 : yylsp++;
1080 : if (yylen == 0)
1081 : {
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;
1087 : }
1088 : else
1089 : {
1090 : yylsp->last_line = (yylsp+yylen-1)->last_line;
1091 : yylsp->last_column = (yylsp+yylen-1)->last_column;
1092 : }
1093 : #endif
1094 :
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. */
1099 :
1100 0 : yyn = yyr1[yyn];
1101 :
1102 0 : yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1103 0 : if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1104 0 : yystate = yytable[yystate];
1105 : else
1106 0 : yystate = yydefgoto[yyn - YYNTBASE];
1107 :
1108 0 : goto yynewstate;
1109 :
1110 : yyerrlab: /* here on detecting error */
1111 :
1112 0 : if (! yyerrstatus)
1113 : /* If not already recovering from an error, report this error. */
1114 : {
1115 0 : ++yynerrs;
1116 :
1117 : #ifdef YYERROR_VERBOSE
1118 : yyn = yypact[yystate];
1119 :
1120 : if (yyn > YYFLAG && yyn < YYLAST)
1121 : {
1122 : int size = 0;
1123 : char *msg;
1124 : int x, count;
1125 :
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)
1134 : {
1135 : strcpy(msg, "parse error");
1136 :
1137 : if (count < 5)
1138 : {
1139 : count = 0;
1140 : for (x = ((yyn < 0) ? -yyn : 0);
1141 : x < (sizeof(yytname) / sizeof(char *)); x++)
1142 : if (yycheck[x + yyn] == x)
1143 : {
1144 : strcat(msg, count == 0 ? ", expecting `" : " or `");
1145 : strcat(msg, yytname[x]);
1146 : strcat(msg, "'");
1147 : count++;
1148 : }
1149 : }
1150 : yyerror(msg);
1151 : free(msg);
1152 : }
1153 : else
1154 : yyerror ("parse error; also virtual memory exceeded");
1155 : }
1156 : else
1157 : #endif /* YYERROR_VERBOSE */
1158 0 : yyerror("parse error");
1159 : }
1160 :
1161 0 : goto yyerrlab1;
1162 : yyerrlab1: /* here on error raised explicitly by an action */
1163 :
1164 0 : if (yyerrstatus == 3)
1165 : {
1166 : /* if just tried and failed to reuse lookahead token after an error, discard it. */
1167 :
1168 : /* return failure if at end of input */
1169 0 : if (yychar == YYEOF)
1170 0 : YYABORT;
1171 :
1172 : #if YYDEBUG != 0
1173 : if (yydebug)
1174 : fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1175 : #endif
1176 :
1177 0 : yychar = YYEMPTY;
1178 : }
1179 :
1180 : /* Else will try to reuse lookahead token
1181 : after shifting the error token. */
1182 :
1183 0 : yyerrstatus = 3; /* Each real token shifted decrements this */
1184 :
1185 0 : goto yyerrhandle;
1186 :
1187 : yyerrdefault: /* current state does not do anything special for the error token. */
1188 :
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
1195 :
1196 : yyerrpop: /* pop the current state because it cannot handle the error token */
1197 :
1198 0 : if (yyssp == yyss) YYABORT;
1199 0 : yyvsp--;
1200 0 : yystate = *--yyssp;
1201 : #ifdef YYLSP_NEEDED
1202 : yylsp--;
1203 : #endif
1204 :
1205 : #if YYDEBUG != 0
1206 : if (yydebug)
1207 : {
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");
1213 : }
1214 : #endif
1215 :
1216 : yyerrhandle:
1217 :
1218 0 : yyn = yypact[yystate];
1219 0 : if (yyn == YYFLAG)
1220 0 : goto yyerrdefault;
1221 :
1222 0 : yyn += YYTERROR;
1223 0 : if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1224 : goto yyerrdefault;
1225 :
1226 0 : yyn = yytable[yyn];
1227 0 : if (yyn < 0)
1228 : {
1229 0 : if (yyn == YYFLAG)
1230 0 : goto yyerrpop;
1231 0 : yyn = -yyn;
1232 0 : goto yyreduce;
1233 : }
1234 0 : else if (yyn == 0)
1235 0 : goto yyerrpop;
1236 :
1237 0 : if (yyn == YYFINAL)
1238 0 : YYACCEPT;
1239 :
1240 : #if YYDEBUG != 0
1241 : if (yydebug)
1242 : fprintf(stderr, "Shifting error token, ");
1243 : #endif
1244 :
1245 0 : *++yyvsp = yylval;
1246 : #ifdef YYLSP_NEEDED
1247 : *++yylsp = yylloc;
1248 : #endif
1249 :
1250 0 : yystate = yyn;
1251 0 : goto yynewstate;
1252 :
1253 : yyacceptlab:
1254 : /* YYACCEPT comes here. */
1255 0 : if (yyfree_stacks)
1256 : {
1257 0 : free (yyss);
1258 0 : free (yyvs);
1259 : #ifdef YYLSP_NEEDED
1260 : free (yyls);
1261 : #endif
1262 : }
1263 0 : return 0;
1264 :
1265 : yyabortlab:
1266 : /* YYABORT comes here. */
1267 0 : if (yyfree_stacks)
1268 : {
1269 0 : free (yyss);
1270 0 : free (yyvs);
1271 : #ifdef YYLSP_NEEDED
1272 : free (yyls);
1273 : #endif
1274 : }
1275 0 : return 1;
1276 : }
1277 :
1278 :
1279 0 : Node *mainParse(const char *_code)
1280 : {
1281 0 : initFlex( _code );
1282 0 : top = 0L;
1283 0 : yyparse();
1284 0 : if( top )
1285 0 : return top;
1286 : else
1287 0 : return 0L;
1288 : }
1289 :
1290 0 : void yyerror(const char * /*err*/)
1291 : {
1292 : // printf("REALKING ERR[%s]\n",err);
1293 : // if error, delete all nodes.
1294 0 : Node *pNode = 0L;
1295 0 : int ncount = nodelist.size();
1296 0 : for( int i = 0 ; i < ncount ; i++){
1297 0 : pNode = nodelist.front();
1298 0 : nodelist.pop_front();
1299 0 : delete pNode;
1300 : }
1301 0 : top = 0L;
1302 0 : }
1303 :
1304 : #ifndef PARSE_DEBUG
1305 0 : int debug(const char * /*format*/, ...)
1306 : {
1307 0 : return 0;
1308 0 : }
1309 : #endif
1310 :
1311 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|