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