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