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 4 : 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 : /* The user can define YYPARSE_PARAM as the name of an argument to be passed
463 : into yyparse. The argument should have type void *.
464 : It should actually point to an object.
465 : Grammar actions can access the variable by casting it
466 : to the proper pointer type. */
467 :
468 : #ifdef YYPARSE_PARAM
469 : #ifdef __cplusplus
470 : #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
471 : #define YYPARSE_PARAM_DECL
472 : #else /* not __cplusplus */
473 : #define YYPARSE_PARAM_ARG YYPARSE_PARAM
474 : #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
475 : #endif /* not __cplusplus */
476 : #else /* not YYPARSE_PARAM */
477 : #define YYPARSE_PARAM_ARG
478 : #define YYPARSE_PARAM_DECL
479 : #endif /* not YYPARSE_PARAM */
480 :
481 : /* Prevent warning if -Wstrict-prototypes. */
482 : #ifdef __GNUC__
483 : #ifdef YYPARSE_PARAM
484 : int yyparse (void *);
485 : #else
486 : int yyparse();
487 : #endif
488 : #endif
489 :
490 : int
491 0 : yyparse(YYPARSE_PARAM_ARG)
492 : YYPARSE_PARAM_DECL
493 : {
494 : int yystate;
495 : int yyn;
496 : short *yyssp;
497 : YYSTYPE *yyvsp;
498 : int yyerrstatus; /* number of tokens to shift before error messages enabled */
499 0 : int yychar1 = 0; /* lookahead token as an internal (translated) token number */
500 :
501 : short yyssa[YYINITDEPTH]; /* the state stack */
502 : YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
503 :
504 0 : short *yyss = yyssa; /* refer to the stacks through separate pointers */
505 0 : YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
506 :
507 : #ifdef YYLSP_NEEDED
508 : YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
509 : YYLTYPE *yyls = yylsa;
510 : YYLTYPE *yylsp;
511 :
512 : #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
513 : #endif
514 :
515 0 : int yystacksize = YYINITDEPTH;
516 0 : int yyfree_stacks = 0;
517 :
518 : #ifdef YYPURE
519 : int yychar;
520 : YYSTYPE yylval;
521 : int yynerrs;
522 : #ifdef YYLSP_NEEDED
523 : YYLTYPE yylloc;
524 : #endif
525 : #endif
526 :
527 : YYSTYPE yyval; /* the variable used to return */
528 0 : yyval.dval = 0;
529 : /* semantic values from the action */
530 : /* routines */
531 :
532 : int yylen;
533 :
534 : #if YYDEBUG != 0
535 : if (yydebug)
536 : fprintf(stderr, "Starting parse\n");
537 : #endif
538 :
539 0 : yystate = 0;
540 0 : yyerrstatus = 0;
541 0 : yynerrs = 0;
542 0 : yychar = YYEMPTY; /* Cause a token to be read. */
543 :
544 : /* Initialize stack pointers.
545 : Waste one element of value and location stack
546 : so that they stay on the same level as the state stack.
547 : The wasted elements are never initialized. */
548 :
549 0 : yyssp = yyss - 1;
550 0 : yyvsp = yyvs;
551 : #ifdef YYLSP_NEEDED
552 : yylsp = yyls;
553 : #endif
554 :
555 : /* Push a new state, which is found in yystate . */
556 : /* In all cases, when you get here, the value and location stacks
557 : have just been pushed. so pushing a state here evens the stacks. */
558 : yynewstate:
559 :
560 0 : *++yyssp = sal::static_int_cast<short>(yystate);
561 :
562 0 : if (yyssp >= yyss + yystacksize - 1)
563 : {
564 : /* Give user a chance to reallocate the stack */
565 : /* Use copies of these so that the &'s don't force the real ones into memory. */
566 0 : YYSTYPE *yyvs1 = yyvs;
567 0 : short *yyss1 = yyss;
568 : #ifdef YYLSP_NEEDED
569 : YYLTYPE *yyls1 = yyls;
570 : #endif
571 :
572 : /* Get the current used size of the three stacks, in elements. */
573 0 : int size = yyssp - yyss + 1;
574 :
575 : #ifdef yyoverflow
576 : /* Each stack pointer address is followed by the size of
577 : the data in use in that stack, in bytes. */
578 : #ifdef YYLSP_NEEDED
579 : /* This used to be a conditional around just the two extra args,
580 : but that might be undefined if yyoverflow is a macro. */
581 : yyoverflow("parser stack overflow",
582 : &yyss1, size * sizeof (*yyssp),
583 : &yyvs1, size * sizeof (*yyvsp),
584 : &yyls1, size * sizeof (*yylsp),
585 : &yystacksize);
586 : #else
587 : yyoverflow("parser stack overflow",
588 : &yyss1, size * sizeof (*yyssp),
589 : &yyvs1, size * sizeof (*yyvsp),
590 : &yystacksize);
591 : #endif
592 :
593 : yyss = yyss1; yyvs = yyvs1;
594 : #ifdef YYLSP_NEEDED
595 : yyls = yyls1;
596 : #endif
597 : #else /* no yyoverflow */
598 : /* Extend the stack our own way. */
599 0 : if (yystacksize >= YYMAXDEPTH)
600 : {
601 0 : yyerror("parser stack overflow");
602 0 : if (yyfree_stacks)
603 : {
604 0 : free (yyss);
605 0 : free (yyvs);
606 : #ifdef YYLSP_NEEDED
607 : free (yyls);
608 : #endif
609 : }
610 0 : return 2;
611 : }
612 0 : yystacksize *= 2;
613 0 : if (yystacksize > YYMAXDEPTH)
614 0 : yystacksize = YYMAXDEPTH;
615 : #ifndef YYSTACK_USE_ALLOCA
616 : yyfree_stacks = 1;
617 : #endif
618 0 : yyss = static_cast<short *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)));
619 : memcpy (yyss, yyss1,
620 0 : size * (unsigned int) sizeof (*yyssp));
621 0 : yyvs = static_cast<YYSTYPE *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)));
622 : memcpy (yyvs, yyvs1,
623 0 : size * (unsigned int) sizeof (*yyvsp));
624 : #ifdef YYLSP_NEEDED
625 : yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
626 : memcpy ((char *)yyls, (char *)yyls1,
627 : size * (unsigned int) sizeof (*yylsp));
628 : #endif
629 : #endif /* no yyoverflow */
630 :
631 0 : yyssp = yyss + size - 1;
632 0 : yyvsp = yyvs + size - 1;
633 : #ifdef YYLSP_NEEDED
634 : yylsp = yyls + size - 1;
635 : #endif
636 :
637 : #if YYDEBUG != 0
638 : if (yydebug)
639 : fprintf(stderr, "Stack size increased to %d\n", yystacksize);
640 : #endif
641 :
642 0 : if (yyssp >= yyss + yystacksize - 1)
643 0 : YYABORT;
644 : }
645 :
646 : #if YYDEBUG != 0
647 : if (yydebug)
648 : fprintf(stderr, "Entering state %d\n", yystate);
649 : #endif
650 :
651 0 : goto yybackup;
652 : yybackup:
653 :
654 : /* Do appropriate processing given the current state. */
655 : /* Read a lookahead token if we need one and don't already have one. */
656 : /* yyresume: */
657 :
658 : /* First try to decide what to do without reference to lookahead token. */
659 :
660 0 : yyn = yypact[yystate];
661 0 : if (yyn == YYFLAG)
662 0 : goto yydefault;
663 :
664 : /* Not known => get a lookahead token if don't already have one. */
665 :
666 : /* yychar is either YYEMPTY or YYEOF
667 : or a valid token in external form. */
668 :
669 0 : if (yychar == YYEMPTY)
670 : {
671 : #if YYDEBUG != 0
672 : if (yydebug)
673 : fprintf(stderr, "Reading a token: ");
674 : #endif
675 0 : yychar = YYLEX;
676 : }
677 :
678 : /* Convert token to internal form (in yychar1) for indexing tables with */
679 :
680 0 : if (yychar <= 0) /* This means end of input. */
681 : {
682 0 : yychar1 = 0;
683 0 : yychar = YYEOF; /* Don't call YYLEX any more */
684 :
685 : #if YYDEBUG != 0
686 : if (yydebug)
687 : fprintf(stderr, "Now at end of input.\n");
688 : #endif
689 : }
690 : else
691 : {
692 0 : yychar1 = YYTRANSLATE(yychar);
693 :
694 : #if YYDEBUG != 0
695 : if (yydebug)
696 : {
697 : fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
698 : /* Give the individual parser a way to print the precise meaning
699 : of a token, for further debugging info. */
700 : #ifdef YYPRINT
701 : YYPRINT (stderr, yychar, yylval);
702 : #endif
703 : fprintf (stderr, ")\n");
704 : }
705 : #endif
706 : }
707 :
708 0 : yyn += yychar1;
709 0 : if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
710 : goto yydefault;
711 :
712 0 : yyn = yytable[yyn];
713 :
714 : /* yyn is what to do for this token type in this state.
715 : Negative => reduce, -yyn is rule number.
716 : Positive => shift, yyn is new state.
717 : New state is final state => don't bother to shift,
718 : just return success.
719 : 0, or most negative number => error. */
720 :
721 0 : if (yyn < 0)
722 : {
723 0 : if (yyn == YYFLAG)
724 0 : goto yyerrlab;
725 0 : yyn = -yyn;
726 0 : goto yyreduce;
727 : }
728 0 : else if (yyn == 0)
729 0 : goto yyerrlab;
730 :
731 0 : if (yyn == YYFINAL)
732 0 : YYACCEPT;
733 :
734 : /* Shift the lookahead token. */
735 :
736 : #if YYDEBUG != 0
737 : if (yydebug)
738 : fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
739 : #endif
740 :
741 : /* Discard the token being shifted unless it is eof. */
742 0 : if (yychar != YYEOF)
743 0 : yychar = YYEMPTY;
744 :
745 0 : *++yyvsp = yylval;
746 : #ifdef YYLSP_NEEDED
747 : *++yylsp = yylloc;
748 : #endif
749 :
750 : /* count tokens shifted since error; after three, turn off error status. */
751 0 : if (yyerrstatus) yyerrstatus--;
752 :
753 0 : yystate = yyn;
754 0 : goto yynewstate;
755 :
756 : /* Do the default action for the current state. */
757 : yydefault:
758 :
759 0 : yyn = yydefact[yystate];
760 0 : if (yyn == 0)
761 0 : goto yyerrlab;
762 :
763 : /* Do a reduction. yyn is the number of a rule to reduce with. */
764 : yyreduce:
765 0 : yylen = yyr2[yyn];
766 0 : if (yylen > 0)
767 0 : yyval = yyvsp[1-yylen]; /* implement default value of the action */
768 :
769 : #if YYDEBUG != 0
770 : if (yydebug)
771 : {
772 : int i;
773 :
774 : fprintf (stderr, "Reducing via rule %d (line %d), ",
775 : yyn, yyrline[yyn]);
776 :
777 : /* Print the symbols being reduced, and their result. */
778 : for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
779 : fprintf (stderr, "%s ", yytname[yyrhs[i]]);
780 : fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
781 : }
782 : #endif
783 :
784 :
785 0 : switch (yyn) {
786 :
787 : case 1:
788 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); ;
789 0 : break;}
790 : case 2:
791 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); ;
792 0 : break;}
793 : case 3:
794 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); ;
795 0 : break;}
796 : case 4:
797 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); ;
798 0 : break;}
799 : case 5:
800 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); ;
801 0 : break;}
802 : case 6:
803 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); ;
804 0 : break;}
805 : case 7:
806 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); ;
807 0 : break;}
808 : case 8:
809 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); ;
810 0 : break;}
811 : case 9:
812 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); ;
813 0 : break;}
814 : case 10:
815 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); ;
816 0 : break;}
817 : case 11:
818 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); ;
819 0 : break;}
820 : case 12:
821 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); ;
822 0 : break;}
823 : case 13:
824 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); ;
825 0 : break;}
826 : case 14:
827 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); ;
828 0 : break;}
829 : case 15:
830 0 : { yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value = strdup("|"); debug("Identifier : '|'\n"); nodelist.push_back(yyval.ptr); ;
831 0 : break;}
832 : case 16:
833 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); ;
834 0 : break;}
835 : case 17:
836 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); ;
837 0 : break;}
838 : case 18:
839 0 : { yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.push_back(yyval.ptr); ;
840 0 : break;}
841 : case 19:
842 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); ;
843 0 : break;}
844 : case 20:
845 0 : { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("("); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
846 0 : break;}
847 : case 21:
848 0 : { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("["); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
849 0 : break;}
850 : case 22:
851 0 : { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("{"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
852 0 : break;}
853 : case 23:
854 0 : { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("<"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
855 0 : break;}
856 : case 24:
857 0 : { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("|"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
858 0 : break;}
859 : case 25:
860 0 : { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value =strdup("||"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
861 0 : break;}
862 : case 26:
863 0 : { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup(yyvsp[0].str); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
864 0 : break;}
865 : case 27:
866 0 : { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(")"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
867 0 : break;}
868 : case 28:
869 0 : { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("]"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
870 0 : break;}
871 : case 29:
872 0 : { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("}"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
873 0 : break;}
874 : case 30:
875 0 : { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(">"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
876 0 : break;}
877 : case 31:
878 0 : { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("|"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
879 0 : break;}
880 : case 32:
881 0 : { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("||"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
882 0 : break;}
883 : case 33:
884 0 : { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(yyvsp[0].str); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
885 0 : break;}
886 : case 34:
887 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); ;
888 0 : break;}
889 : case 35:
890 0 : { yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.push_back(yyval.ptr); ;
891 0 : break;}
892 : case 36:
893 0 : { yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.push_back(yyval.ptr); ;
894 0 : break;}
895 : case 37:
896 0 : { yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.push_back(yyval.ptr); ;
897 0 : break;}
898 : case 38:
899 0 : { yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.push_back(yyval.ptr); ;
900 0 : break;}
901 : case 39:
902 0 : { yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.push_back(yyval.ptr); ;
903 0 : break;}
904 : case 40:
905 0 : { yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.push_back(yyval.ptr); ;
906 0 : break;}
907 : case 41:
908 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); ;
909 0 : break;}
910 : case 42:
911 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); ;
912 0 : break;}
913 : case 43:
914 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); ;
915 0 : break;}
916 : case 44:
917 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); ;
918 0 : break;}
919 : case 45:
920 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); ;
921 0 : break;}
922 : case 46:
923 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); ;
924 0 : break;}
925 : case 47:
926 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); ;
927 0 : break;}
928 : case 48:
929 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); ;
930 0 : break;}
931 : case 49:
932 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); ;
933 0 : break;}
934 : case 50:
935 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); ;
936 0 : break;}
937 : case 51:
938 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); ;
939 0 : break;}
940 : case 52:
941 0 : { yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("BeginExpr\n"); ;
942 0 : break;}
943 : case 53:
944 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"); ;
945 0 : break;}
946 : case 54:
947 0 : { yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("EndExpr\n"); ;
948 0 : break;}
949 : case 55:
950 0 : { yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); top = yyval.ptr; debug("MathML\n"); ;
951 0 : break;}
952 : case 56:
953 0 : { yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("Lines\n"); ;
954 0 : break;}
955 : case 57:
956 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"); ;
957 0 : break;}
958 : case 58:
959 0 : { yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.push_back(yyval.ptr); debug("Line\n"); ;
960 0 : break;}
961 : case 59:
962 0 : { yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.push_back(yyval.ptr); ;
963 0 : break;}
964 : case 60:
965 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); ;
966 0 : break;}
967 : case 61:
968 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.push_back(yyval.ptr);;
969 0 : break;}
970 : case 62:
971 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.push_back(yyval.ptr);;
972 0 : break;}
973 : case 63:
974 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.push_back(yyval.ptr);;
975 0 : break;}
976 : case 64:
977 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.push_back(yyval.ptr);;
978 0 : break;}
979 : case 65:
980 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.push_back(yyval.ptr);;
981 0 : break;}
982 : case 66:
983 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.push_back(yyval.ptr);;
984 0 : break;}
985 : case 67:
986 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.push_back(yyval.ptr);;
987 0 : break;}
988 : case 68:
989 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.push_back(yyval.ptr);;
990 0 : break;}
991 : case 69:
992 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.push_back(yyval.ptr);;
993 0 : break;}
994 : case 70:
995 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.push_back(yyval.ptr);;
996 0 : break;}
997 : case 71:
998 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.push_back(yyval.ptr);;
999 0 : break;}
1000 : case 72:
1001 0 : { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.push_back(yyval.ptr);;
1002 0 : break;}
1003 : }
1004 : /* the action file gets copied in place of this dollarsign */
1005 :
1006 0 : yyvsp -= yylen;
1007 0 : yyssp -= yylen;
1008 : #ifdef YYLSP_NEEDED
1009 : yylsp -= yylen;
1010 : #endif
1011 :
1012 : #if YYDEBUG != 0
1013 : if (yydebug)
1014 : {
1015 : short *ssp1 = yyss - 1;
1016 : fprintf (stderr, "state stack now");
1017 : while (ssp1 != yyssp)
1018 : fprintf (stderr, " %d", *++ssp1);
1019 : fprintf (stderr, "\n");
1020 : }
1021 : #endif
1022 :
1023 0 : *++yyvsp = yyval;
1024 :
1025 : #ifdef YYLSP_NEEDED
1026 : yylsp++;
1027 : if (yylen == 0)
1028 : {
1029 : yylsp->first_line = yylloc.first_line;
1030 : yylsp->first_column = yylloc.first_column;
1031 : yylsp->last_line = (yylsp-1)->last_line;
1032 : yylsp->last_column = (yylsp-1)->last_column;
1033 : yylsp->text = 0;
1034 : }
1035 : else
1036 : {
1037 : yylsp->last_line = (yylsp+yylen-1)->last_line;
1038 : yylsp->last_column = (yylsp+yylen-1)->last_column;
1039 : }
1040 : #endif
1041 :
1042 : /* Now "shift" the result of the reduction.
1043 : Determine what state that goes to,
1044 : based on the state we popped back to
1045 : and the rule number reduced by. */
1046 :
1047 0 : yyn = yyr1[yyn];
1048 :
1049 0 : yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1050 0 : if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1051 0 : yystate = yytable[yystate];
1052 : else
1053 0 : yystate = yydefgoto[yyn - YYNTBASE];
1054 :
1055 0 : goto yynewstate;
1056 :
1057 : yyerrlab: /* here on detecting error */
1058 :
1059 0 : if (! yyerrstatus)
1060 : /* If not already recovering from an error, report this error. */
1061 : {
1062 0 : ++yynerrs;
1063 :
1064 : #ifdef YYERROR_VERBOSE
1065 : yyn = yypact[yystate];
1066 :
1067 : if (yyn > YYFLAG && yyn < YYLAST)
1068 : {
1069 : int size = 0;
1070 : char *msg;
1071 : int x, count;
1072 :
1073 : count = 0;
1074 : /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1075 : for (x = ((yyn < 0) ? -yyn : 0);
1076 : x < (sizeof(yytname) / sizeof(char *)); x++)
1077 : if (yycheck[x + yyn] == x)
1078 : size += strlen(yytname[x]) + 15, count++;
1079 : msg = (char *) malloc(size + 15);
1080 : if (msg != 0)
1081 : {
1082 : strcpy(msg, "parse error");
1083 :
1084 : if (count < 5)
1085 : {
1086 : count = 0;
1087 : for (x = ((yyn < 0) ? -yyn : 0);
1088 : x < (sizeof(yytname) / sizeof(char *)); x++)
1089 : if (yycheck[x + yyn] == x)
1090 : {
1091 : strcat(msg, count == 0 ? ", expecting `" : " or `");
1092 : strcat(msg, yytname[x]);
1093 : strcat(msg, "'");
1094 : count++;
1095 : }
1096 : }
1097 : yyerror(msg);
1098 : free(msg);
1099 : }
1100 : else
1101 : yyerror ("parse error; also virtual memory exceeded");
1102 : }
1103 : else
1104 : #endif /* YYERROR_VERBOSE */
1105 0 : yyerror("parse error");
1106 : }
1107 :
1108 0 : goto yyerrlab1;
1109 : yyerrlab1: /* here on error raised explicitly by an action */
1110 :
1111 0 : if (yyerrstatus == 3)
1112 : {
1113 : /* if just tried and failed to reuse lookahead token after an error, discard it. */
1114 :
1115 : /* return failure if at end of input */
1116 0 : if (yychar == YYEOF)
1117 0 : YYABORT;
1118 :
1119 : #if YYDEBUG != 0
1120 : if (yydebug)
1121 : fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1122 : #endif
1123 :
1124 0 : yychar = YYEMPTY;
1125 : }
1126 :
1127 : /* Else will try to reuse lookahead token
1128 : after shifting the error token. */
1129 :
1130 0 : yyerrstatus = 3; /* Each real token shifted decrements this */
1131 :
1132 0 : goto yyerrhandle;
1133 :
1134 : yyerrdefault: /* current state does not do anything special for the error token. */
1135 :
1136 : #if 0
1137 : /* This is wrong; only states that explicitly want error tokens
1138 : should shift them. */
1139 : yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1140 : if (yyn) goto yydefault;
1141 : #endif
1142 :
1143 : yyerrpop: /* pop the current state because it cannot handle the error token */
1144 :
1145 0 : if (yyssp == yyss) YYABORT;
1146 0 : yyvsp--;
1147 0 : yystate = *--yyssp;
1148 : #ifdef YYLSP_NEEDED
1149 : yylsp--;
1150 : #endif
1151 :
1152 : #if YYDEBUG != 0
1153 : if (yydebug)
1154 : {
1155 : short *ssp1 = yyss - 1;
1156 : fprintf (stderr, "Error: state stack now");
1157 : while (ssp1 != yyssp)
1158 : fprintf (stderr, " %d", *++ssp1);
1159 : fprintf (stderr, "\n");
1160 : }
1161 : #endif
1162 :
1163 : yyerrhandle:
1164 :
1165 0 : yyn = yypact[yystate];
1166 0 : if (yyn == YYFLAG)
1167 0 : goto yyerrdefault;
1168 :
1169 0 : yyn += YYTERROR;
1170 0 : if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1171 : goto yyerrdefault;
1172 :
1173 0 : yyn = yytable[yyn];
1174 0 : if (yyn < 0)
1175 : {
1176 0 : if (yyn == YYFLAG)
1177 0 : goto yyerrpop;
1178 0 : yyn = -yyn;
1179 0 : goto yyreduce;
1180 : }
1181 0 : else if (yyn == 0)
1182 0 : goto yyerrpop;
1183 :
1184 0 : if (yyn == YYFINAL)
1185 0 : YYACCEPT;
1186 :
1187 : #if YYDEBUG != 0
1188 : if (yydebug)
1189 : fprintf(stderr, "Shifting error token, ");
1190 : #endif
1191 :
1192 0 : *++yyvsp = yylval;
1193 : #ifdef YYLSP_NEEDED
1194 : *++yylsp = yylloc;
1195 : #endif
1196 :
1197 0 : yystate = yyn;
1198 0 : goto yynewstate;
1199 :
1200 : yyacceptlab:
1201 : /* YYACCEPT comes here. */
1202 0 : if (yyfree_stacks)
1203 : {
1204 0 : free (yyss);
1205 0 : free (yyvs);
1206 : #ifdef YYLSP_NEEDED
1207 : free (yyls);
1208 : #endif
1209 : }
1210 0 : return 0;
1211 :
1212 : yyabortlab:
1213 : /* YYABORT comes here. */
1214 0 : if (yyfree_stacks)
1215 : {
1216 0 : free (yyss);
1217 0 : free (yyvs);
1218 : #ifdef YYLSP_NEEDED
1219 : free (yyls);
1220 : #endif
1221 : }
1222 0 : return 1;
1223 : }
1224 :
1225 :
1226 0 : Node *mainParse(const char *_code)
1227 : {
1228 0 : initFlex( _code );
1229 0 : top = 0L;
1230 0 : yyparse();
1231 0 : if( top )
1232 0 : return top;
1233 : else
1234 0 : return 0L;
1235 : }
1236 :
1237 0 : void yyerror(const char * /*err*/)
1238 : {
1239 : // printf("REALKING ERR[%s]\n",err);
1240 : // if error, delete all nodes.
1241 0 : Node *pNode = 0L;
1242 0 : int ncount = nodelist.size();
1243 0 : for( int i = 0 ; i < ncount ; i++){
1244 0 : pNode = nodelist.front();
1245 0 : nodelist.pop_front();
1246 0 : delete pNode;
1247 : }
1248 0 : top = 0L;
1249 0 : }
1250 :
1251 : #ifndef PARSE_DEBUG
1252 0 : int debug(const char * /*format*/, ...)
1253 : {
1254 0 : return 0;
1255 12 : }
1256 : #endif
1257 :
1258 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|