Bump version to 24.04.3.4
[LibreOffice.git] / hwpfilter / source / grammar.cxx
blob199aab3432083cfa0d76621e42f6c34ccffc805a
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 YYMAXDEPTH
25 #define YYMAXDEPTH 0
26 #endif
28 #include <vector>
29 #include <stdlib.h>
30 #include <string.h>
32 #include "grammar.hxx"
33 #include "lexer.hxx"
34 #include "nodes.h"
36 extern "C" {
37 #include "grammar.h"
40 std::vector<std::unique_ptr<Node>> nodelist;
42 static void yyerror(const char *);
44 static Node *top=nullptr;
46 int Node::count = 0;
48 #ifdef PARSE_DEBUG
49 #define debug printf
50 #else
51 static int debug(const char *format, ...);
52 #endif
54 #include <stdio.h>
56 #define YYFINAL 102
57 #define YYFLAG -32768
58 #define YYNTBASE 43
60 #define YYTRANSLATE(x) (static_cast<unsigned>(x) <= 285 ? yytranslate[x] : 66)
62 const char yytranslate[] = { 0,
63 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
64 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
65 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
66 2, 2, 2, 2, 2, 2, 2, 2, 2, 33,
67 37, 2, 2, 2, 2, 2, 2, 2, 2, 2,
68 2, 2, 2, 2, 2, 2, 2, 2, 2, 36,
69 2, 40, 2, 2, 2, 2, 2, 2, 2, 2,
70 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
71 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
72 34, 2, 38, 42, 41, 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 2, 2, 35, 32, 39, 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, 2, 2, 2, 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, 1, 3, 4, 5, 6,
89 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
90 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
91 27, 28, 29, 30, 31
95 const short yyr1[] = { 0,
96 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
97 43, 43, 43, 43, 43, 43, 43, 44, 44, 45,
98 45, 45, 45, 45, 45, 45, 46, 46, 46, 46,
99 46, 46, 46, 47, 48, 48, 49, 49, 50, 50,
100 51, 51, 51, 52, 53, 54, 55, 56, 57, 58,
101 58, 59, 59, 60, 61, 62, 62, 63, 64, 64,
102 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
103 65, 65
106 const short yyr2[] = { 0,
107 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
109 2, 2, 2, 2, 3, 1, 2, 2, 2, 2,
110 2, 3, 1, 3, 3, 2, 3, 2, 3, 2,
111 3, 3, 5, 3, 5, 1, 2, 1, 2, 2,
112 3, 2, 3, 2, 1, 1, 3, 1, 1, 2,
113 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
114 1, 1
117 const short yydefact[] = { 0,
118 46, 1, 4, 10, 9, 14, 2, 3, 5, 6,
119 0, 0, 12, 13, 48, 7, 8, 17, 11, 0,
120 0, 0, 26, 16, 15, 0, 0, 18, 70, 0,
121 63, 62, 61, 64, 65, 66, 0, 69, 0, 67,
122 68, 71, 72, 55, 56, 58, 59, 0, 0, 50,
123 0, 0, 52, 54, 24, 20, 21, 22, 23, 36,
124 0, 38, 0, 19, 0, 47, 49, 0, 60, 0,
125 0, 40, 0, 0, 51, 44, 53, 25, 35, 0,
126 37, 0, 33, 34, 57, 61, 41, 42, 39, 0,
127 31, 27, 28, 29, 30, 0, 45, 32, 43, 0,
128 0, 0
131 const short yydefgoto[] = { 28,
132 29, 30, 84, 31, 32, 33, 51, 34, 35, 36,
133 37, 38, 39, 40, 41, 42, 43, 100, 44, 45,
134 46, 47
137 const short yypact[] = { 393,
138 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
139 -30, -19,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -19,
140 -19, -3,-32768,-32768,-32768, 290, 107,-32768, 425, 393,
141 -32768,-32768,-32768,-32768,-32768,-32768, -19,-32768, -19,-32768,
142 -32768,-32768,-32768, -20,-32768, 393, -21, 218, 107,-32768,
143 -19, -19, -19,-32768, -15,-32768,-32768,-32768,-32768,-32768,
144 325,-32768, 70,-32768, 360,-32768,-32768, 393, -21, 393,
145 393,-32768, 254, 144,-32768,-32768,-32768,-32768,-32768, 393,
146 -32768, -25,-32768,-32768,-32768, -31, -21, -21,-32768, 181,
147 -14,-32768,-32768,-32768,-32768, -19,-32768,-32768,-32768, 22,
148 23,-32768
151 const short yypgoto[] = { -2,
152 -32768,-32768,-32768,-32768,-32768, -11,-32768,-32768,-32768,-32768,
153 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -33,
154 -24, -27
158 #define YYLAST 457
161 const short yytable[] = { 50,
162 52, 61, 63, 48, 49, 65, 91, 68, 53, 54,
163 96, 92, 93, 94, 95, 49, 78, 98, 69, 70,
164 71, 101, 102, 73, 74, 66, 64, 67, 55, 56,
165 57, 58, 59, 69, 85, 69, 0, 69, 0, 75,
166 76, 77, 87, 88, 0, 69, 69, 0, 0, 0,
167 0, 0, 0, 0, 0, 90, 0, 0, 86, 0,
168 0, 0, 69, 0, 0, 0, 0, 0, 0, 0,
169 0, 0, 1, 2, 3, 4, 5, 6, 7, 8,
170 9, 10, 11, 12, 99, 80, 13, 14, 15, 16,
171 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
172 24, 25, 26, 0, 27, 0, 0, 0, 81, 1,
173 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
174 12, 0, 0, 13, 14, 15, 16, 17, 18, 19,
175 20, 21, 22, 0, 0, 23, 0, 24, 25, 26,
176 0, 27, 0, 0, 0, 62, 1, 2, 3, 4,
177 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
178 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
179 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
180 0, 0, 81, 1, 2, 3, 4, 5, 6, 7,
181 8, 9, 10, 11, 12, 0, 0, 13, 14, 15,
182 16, 17, 18, 19, 20, 21, 22, 0, 0, 23,
183 0, 24, 25, 26, 0, 27, 0, 0, 0, 97,
184 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
185 11, 12, 0, 0, 13, 14, 15, 16, 17, 18,
186 19, 20, 21, 22, 0, 0, 23, 0, 24, 25,
187 26, 0, 27, 0, 0, 72, 1, 2, 3, 4,
188 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
189 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
190 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
191 0, 89, 1, 2, 3, 4, 5, 6, 7, 8,
192 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
193 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
194 24, 25, 26, 0, 27, 0, 60, 1, 2, 3,
195 4, 5, 6, 7, 8, 9, 10, 11, 12, 0,
196 0, 13, 14, 15, 16, 17, 18, 19, 20, 21,
197 22, 0, 0, 23, 0, 24, 25, 26, 0, 27,
198 0, 79, 1, 2, 3, 4, 5, 6, 7, 8,
199 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
200 17, 18, 19, 20, 21, 22, 82, 0, 23, 83,
201 24, 25, 26, 0, 27, 1, 2, 3, 4, 5,
202 6, 7, 8, 9, 10, 11, 12, 0, 0, 13,
203 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
204 0, 23, 0, 24, 25, 26, 0, 27, 2, 3,
205 4, 5, 6, 7, 8, 9, 10, 0, 0, 0,
206 0, 13, 14, 0, 16, 17, 18, 19, 0, 0,
207 0, 0, 0, 0, 0, 24, 25
210 const short yycheck[] = { 11,
211 12, 26, 27, 34, 35, 30, 32, 28, 20, 21,
212 42, 37, 38, 39, 40, 35, 32, 32, 46, 41,
213 42, 0, 0, 48, 49, 37, 29, 39, 32, 33,
214 34, 35, 36, 61, 68, 63, -1, 65, -1, 51,
215 52, 53, 70, 71, -1, 73, 74, -1, -1, -1,
216 -1, -1, -1, -1, -1, 80, -1, -1, 70, -1,
217 -1, -1, 90, -1, -1, -1, -1, -1, -1, -1,
218 -1, -1, 3, 4, 5, 6, 7, 8, 9, 10,
219 11, 12, 13, 14, 96, 16, 17, 18, 19, 20,
220 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
221 31, 32, 33, -1, 35, -1, -1, -1, 39, 3,
222 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
223 14, -1, -1, 17, 18, 19, 20, 21, 22, 23,
224 24, 25, 26, -1, -1, 29, -1, 31, 32, 33,
225 -1, 35, -1, -1, -1, 39, 3, 4, 5, 6,
226 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
227 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
228 -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
229 -1, -1, 39, 3, 4, 5, 6, 7, 8, 9,
230 10, 11, 12, 13, 14, -1, -1, 17, 18, 19,
231 20, 21, 22, 23, 24, 25, 26, -1, -1, 29,
232 -1, 31, 32, 33, -1, 35, -1, -1, -1, 39,
233 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
234 13, 14, -1, -1, 17, 18, 19, 20, 21, 22,
235 23, 24, 25, 26, -1, -1, 29, -1, 31, 32,
236 33, -1, 35, -1, -1, 38, 3, 4, 5, 6,
237 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
238 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
239 -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
240 -1, 38, 3, 4, 5, 6, 7, 8, 9, 10,
241 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
242 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
243 31, 32, 33, -1, 35, -1, 37, 3, 4, 5,
244 6, 7, 8, 9, 10, 11, 12, 13, 14, -1,
245 -1, 17, 18, 19, 20, 21, 22, 23, 24, 25,
246 26, -1, -1, 29, -1, 31, 32, 33, -1, 35,
247 -1, 37, 3, 4, 5, 6, 7, 8, 9, 10,
248 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
249 21, 22, 23, 24, 25, 26, 27, -1, 29, 30,
250 31, 32, 33, -1, 35, 3, 4, 5, 6, 7,
251 8, 9, 10, 11, 12, 13, 14, -1, -1, 17,
252 18, 19, 20, 21, 22, 23, 24, 25, 26, -1,
253 -1, 29, -1, 31, 32, 33, -1, 35, 4, 5,
254 6, 7, 8, 9, 10, 11, 12, -1, -1, -1,
255 -1, 17, 18, -1, 20, 21, 22, 23, -1, -1,
256 -1, -1, -1, -1, -1, 31, 32
258 /* This file comes from bison-1.28. */
260 /* Skeleton output parser for bison,
261 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
263 This program is free software; you can redistribute it and/or modify
264 it under the terms of the GNU General Public License as published by
265 the Free Software Foundation; either version 2, or (at your option)
266 any later version.
268 This program is distributed in the hope that it will be useful,
269 but WITHOUT ANY WARRANTY; without even the implied warranty of
270 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
271 GNU General Public License for more details.
273 You should have received a copy of the GNU General Public License
274 along with this program; if not, write to the Free Software
275 Foundation, Inc., 59 Temple Place - Suite 330,
276 Boston, MA 02111-1307, USA. */
278 /* As a special exception, when this file is copied by Bison into a
279 Bison output file, you may use that output file without restriction.
280 This special exception was added by the Free Software Foundation
281 in version 1.24 of Bison. */
283 /* This is the parser code that is written into each bison parser
284 when the %semantic_parser declaration is not specified in the grammar.
285 It was written by Richard Stallman by simplifying the hairy parser
286 used when %semantic_parser is specified. */
288 /* Note: there must be only one dollar sign in this file.
289 It is replaced by the list of actions, each action
290 as one case of the switch. */
292 #define YYEMPTY -2
293 #define YYEOF 0
294 #define YYACCEPT goto yyacceptlab
295 #define YYABORT goto yyabortlab
297 #define YYTERROR 1
299 #define YYLEX yylex()
301 /* If nonreentrant, generate the variables here */
303 static int yychar; /* the lookahead symbol */
304 YYSTYPE yylval; /* the semantic value of the */
305 /* lookahead symbol */
307 static int yynerrs; /* number of parse errors so far */
309 /* YYINITDEPTH indicates the initial size of the parser's stacks */
311 #ifndef YYINITDEPTH
312 #define YYINITDEPTH 200
313 #endif
315 /* YYMAXDEPTH is the maximum size the stacks can grow to
316 (effective only if the built-in stack extension method is used). */
318 #if YYMAXDEPTH == 0
319 #undef YYMAXDEPTH
320 #endif
322 #ifndef YYMAXDEPTH
323 #define YYMAXDEPTH 10000
324 #endif
326 #define YYPARSE_PARAM_ARG
327 #define YYPARSE_PARAM_DECL
329 /* Prevent warning if -Wstrict-prototypes. */
330 #ifdef __GNUC__
331 static int yyparse();
332 #endif
334 static int
335 yyparse(YYPARSE_PARAM_ARG)
336 YYPARSE_PARAM_DECL
338 int yystate;
339 int yyn;
340 short *yyssp;
341 YYSTYPE *yyvsp;
342 int yyerrstatus; /* number of tokens to shift before error messages enabled */
343 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
345 short yyssa[YYINITDEPTH]; /* the state stack */
346 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
348 short *yyss = yyssa; /* refer to the stacks through separate pointers */
349 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
351 int yystacksize = YYINITDEPTH;
352 int yyfree_stacks = 0;
354 YYSTYPE yyval; /* the variable used to return */
355 yyval.dval = nullptr;
356 /* semantic values from the action */
357 /* routines */
359 int yylen;
361 yystate = 0;
362 yyerrstatus = 0;
363 yynerrs = 0;
364 yychar = YYEMPTY; /* Cause a token to be read. */
366 /* Initialize stack pointers.
367 Waste one element of value and location stack
368 so that they stay on the same level as the state stack.
369 The wasted elements are never initialized. */
371 yyssp = yyss - 1;
372 yyvsp = yyvs;
374 /* Push a new state, which is found in yystate . */
375 /* In all cases, when you get here, the value and location stacks
376 have just been pushed. So pushing a state here events the stacks. */
377 yynewstate:
379 *++yyssp = sal::static_int_cast<short>(yystate);
381 if (yyssp >= yyss + yystacksize - 1)
383 /* Give user a chance to reallocate the stack */
384 /* Use copies of these so that the &'s don't force the real ones into memory. */
385 YYSTYPE *yyvs1 = yyvs;
386 short *yyss1 = yyss;
388 /* Get the current used size of the three stacks, in elements. */
389 int size = yyssp - yyss + 1;
391 /* Extend the stack our own way. */
392 if (yystacksize >= YYMAXDEPTH)
394 yyerror("parser stack overflow");
395 if (yyfree_stacks)
397 free (yyss);
398 free (yyvs);
400 return 2;
402 yystacksize *= 2;
403 if (yystacksize > YYMAXDEPTH)
404 yystacksize = YYMAXDEPTH;
405 yyfree_stacks = 1;
406 yyss = static_cast<short *>(malloc (yystacksize * sizeof (*yyssp)));
407 memcpy (yyss, yyss1, size * sizeof (*yyssp));
408 yyvs = static_cast<YYSTYPE *>(malloc (yystacksize * sizeof (*yyvsp)));
409 memcpy (yyvs, yyvs1, size * sizeof (*yyvsp));
411 // https://lists.gnu.org/archive/html/bug-bison/2001-11/msg00021.html
412 if (yyss1 != yyssa)
413 free (yyss1);
414 if (yyvs1 != yyvsa)
415 free (yyvs1);
417 yyssp = yyss + size - 1;
418 yyvsp = yyvs + size - 1;
420 if (yyssp >= yyss + yystacksize - 1)
421 YYABORT;
424 goto yybackup;
425 yybackup:
427 /* Do appropriate processing given the current state. */
428 /* Read a lookahead token if we need one and don't already have one. */
429 /* yyresume: */
431 /* First try to decide what to do without reference to lookahead token. */
433 yyn = yypact[yystate];
434 if (yyn == YYFLAG)
435 goto yydefault;
437 /* Not known => get a lookahead token if don't already have one. */
439 /* yychar is either YYEMPTY or YYEOF
440 or a valid token in external form. */
442 if (yychar == YYEMPTY)
444 yychar = YYLEX;
447 /* Convert token to internal form (in yychar1) for indexing tables with */
449 if (yychar <= 0) /* This means end of input. */
451 yychar1 = 0;
452 yychar = YYEOF; /* Don't call YYLEX any more */
455 else
457 yychar1 = YYTRANSLATE(yychar);
461 yyn += yychar1;
462 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
463 goto yydefault;
465 yyn = yytable[yyn];
467 /* yyn is what to do for this token type in this state.
468 Negative => reduce, -yyn is rule number.
469 Positive => shift, yyn is new state.
470 New state is final state => don't bother to shift,
471 just return success.
472 0, or most negative number => error. */
474 if (yyn < 0)
476 if (yyn == YYFLAG)
477 goto yyerrlab;
478 yyn = -yyn;
479 goto yyreduce;
481 else if (yyn == 0)
482 goto yyerrlab;
484 if (yyn == YYFINAL)
485 YYACCEPT;
487 /* Shift the lookahead token. */
489 /* Discard the token being shifted unless it is eof. */
490 if (yychar != YYEOF)
491 yychar = YYEMPTY;
493 *++yyvsp = yylval;
495 /* count tokens shifted since error; after three, turn off error status. */
496 if (yyerrstatus) yyerrstatus--;
498 yystate = yyn;
499 goto yynewstate;
501 /* Do the default action for the current state. */
502 yydefault:
504 yyn = yydefact[yystate];
505 if (yyn == 0)
506 goto yyerrlab;
508 /* Do a reduction. yyn is the number of a rule to reduce with. */
509 yyreduce:
510 yylen = yyr2[yyn];
511 if (yylen > 0)
512 yyval = yyvsp[1-yylen]; /* implement default value of the action */
514 switch (yyn) {
516 case 1:
517 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
518 break;}
519 case 2:
520 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
521 break;}
522 case 3:
523 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
524 break;}
525 case 4:
526 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
527 break;}
528 case 5:
529 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
530 break;}
531 case 6:
532 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
533 break;}
534 case 7:
535 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
536 break;}
537 case 8:
538 { yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
539 break;}
540 case 9:
541 { yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
542 break;}
543 case 10:
544 { yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
545 break;}
546 case 11:
547 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
548 break;}
549 case 12:
550 { yyval.ptr = new Node(ID_DELIMITER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
551 break;}
552 case 13:
553 { yyval.ptr = new Node(ID_DELIMITER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
554 break;}
555 case 14:
556 { yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
557 break;}
558 case 15:
559 { yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value.reset(strdup("|")); debug("Identifier : '|'\n"); nodelist.emplace_back(yyval.ptr);
560 break;}
561 case 16:
562 { yyval.ptr = new Node(ID_NUMBER); yyval.ptr->value.reset(strdup(yyvsp[0].dval)); debug("Number : %s\n",yyvsp[0].dval); nodelist.emplace_back(yyval.ptr);
563 break;}
564 case 17:
565 { yyval.ptr = new Node(ID_STRING); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("String : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
566 break;}
567 case 18:
568 { yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.emplace_back(yyval.ptr);
569 break;}
570 case 19:
571 { 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);
572 break;}
573 case 20:
574 { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("(")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
575 break;}
576 case 21:
577 { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("[")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
578 break;}
579 case 22:
580 { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("{")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
581 break;}
582 case 23:
583 { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("<")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
584 break;}
585 case 24:
586 { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("|")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
587 break;}
588 case 25:
589 { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("||")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
590 break;}
591 case 26:
592 { yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
593 break;}
594 case 27:
595 { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup(")")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
596 break;}
597 case 28:
598 { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("]")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
599 break;}
600 case 29:
601 { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("}")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
602 break;}
603 case 30:
604 { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup(">")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
605 break;}
606 case 31:
607 { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("|")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
608 break;}
609 case 32:
610 { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("||")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
611 break;}
612 case 33:
613 { yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
614 break;}
615 case 34:
616 { 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);
617 break;}
618 case 35:
619 { yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.emplace_back(yyval.ptr);
620 break;}
621 case 36:
622 { yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.emplace_back(yyval.ptr);
623 break;}
624 case 37:
625 { yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.emplace_back(yyval.ptr);
626 break;}
627 case 38:
628 { yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.emplace_back(yyval.ptr);
629 break;}
630 case 39:
631 { yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.emplace_back(yyval.ptr);
632 break;}
633 case 40:
634 { yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.emplace_back(yyval.ptr);
635 break;}
636 case 41:
637 { 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);
638 break;}
639 case 42:
640 { 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);
641 break;}
642 case 43:
643 { 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);
644 break;}
645 case 44:
646 { 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);
647 break;}
648 case 45:
649 { 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);
650 break;}
651 case 46:
652 { yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Accent : %s\n", yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
653 break;}
654 case 47:
655 { 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);
656 break;}
657 case 48:
658 { yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Decoration : %s\n", yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
659 break;}
660 case 49:
661 { 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);
662 break;}
663 case 50:
664 { yyval.ptr = new Node(ID_SQRTEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-1].str); nodelist.emplace_back(yyval.ptr);
665 break;}
666 case 51:
667 { 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);
668 break;}
669 case 52:
670 { yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.emplace_back(yyval.ptr); debug("BeginExpr\n");
671 break;}
672 case 53:
673 { 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");
674 break;}
675 case 54:
676 { yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.emplace_back(yyval.ptr); debug("EndExpr\n");
677 break;}
678 case 55:
679 { yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.emplace_back(yyval.ptr); top = yyval.ptr; debug("MathML\n");
680 break;}
681 case 56:
682 { yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.emplace_back(yyval.ptr); debug("Lines\n");
683 break;}
684 case 57:
685 { 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");
686 break;}
687 case 58:
688 { yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.emplace_back(yyval.ptr); debug("Line\n");
689 break;}
690 case 59:
691 { yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.emplace_back(yyval.ptr);
692 break;}
693 case 60:
694 { 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);
695 break;}
696 case 61:
697 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.emplace_back(yyval.ptr);
698 break;}
699 case 62:
700 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.emplace_back(yyval.ptr);
701 break;}
702 case 63:
703 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.emplace_back(yyval.ptr);
704 break;}
705 case 64:
706 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.emplace_back(yyval.ptr);
707 break;}
708 case 65:
709 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.emplace_back(yyval.ptr);
710 break;}
711 case 66:
712 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.emplace_back(yyval.ptr);
713 break;}
714 case 67:
715 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.emplace_back(yyval.ptr);
716 break;}
717 case 68:
718 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.emplace_back(yyval.ptr);
719 break;}
720 case 69:
721 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.emplace_back(yyval.ptr);
722 break;}
723 case 70:
724 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.emplace_back(yyval.ptr);
725 break;}
726 case 71:
727 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.emplace_back(yyval.ptr);
728 break;}
729 case 72:
730 { yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.emplace_back(yyval.ptr);
731 break;}
733 /* the action file gets copied in place of this dollarsign */
735 yyvsp -= yylen;
736 yyssp -= yylen;
738 *++yyvsp = yyval;
740 /* Now "shift" the result of the reduction.
741 Determine what state that goes to,
742 based on the state we popped back to
743 and the rule number reduced by. */
745 yyn = yyr1[yyn];
747 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
748 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
749 yystate = yytable[yystate];
750 else
751 yystate = yydefgoto[yyn - YYNTBASE];
753 goto yynewstate;
755 yyerrlab: /* here on detecting error */
757 if (! yyerrstatus)
758 /* If not already recovering from an error, report this error. */
760 ++yynerrs;
762 #ifdef YYERROR_VERBOSE
763 yyn = yypact[yystate];
765 if (yyn > YYFLAG && yyn < YYLAST)
767 int size = 0;
768 char *msg;
769 int x, count;
771 count = 0;
772 /* Start X at -yyn if negative to avoid negative indexes in yycheck. */
773 for (x = ((yyn < 0) ? -yyn : 0);
774 x < (sizeof(yytname) / sizeof(char *)); x++)
775 if (yycheck[x + yyn] == x)
776 size += strlen(yytname[x]) + 15, count++;
777 msg = (char *) malloc(size + 15);
778 if (msg != 0)
780 strcpy(msg, "parse error");
782 if (count < 5)
784 count = 0;
785 for (x = ((yyn < 0) ? -yyn : 0);
786 x < (sizeof(yytname) / sizeof(char *)); x++)
787 if (yycheck[x + yyn] == x)
789 strcat(msg, count == 0 ? ", expecting `" : " or `");
790 strcat(msg, yytname[x]);
791 strcat(msg, "'");
792 count++;
795 yyerror(msg);
796 free(msg);
798 else
799 yyerror ("parse error; also virtual memory exceeded");
801 else
802 #endif /* YYERROR_VERBOSE */
803 yyerror("parse error");
806 goto yyerrlab1;
807 yyerrlab1: /* here on error raised explicitly by an action */
809 if (yyerrstatus == 3)
811 /* if just tried and failed to reuse lookahead token after an error, discard it. */
813 /* return failure if at end of input */
814 if (yychar == YYEOF)
815 YYABORT;
817 yychar = YYEMPTY;
820 /* Else will try to reuse lookahead token
821 after shifting the error token. */
823 yyerrstatus = 3; /* Each real token shifted decrements this */
825 goto yyerrhandle;
827 yyerrdefault: /* current state does not do anything special for the error token. */
829 #if 0
830 /* This is wrong; only states that explicitly want error tokens
831 should shift them. */
832 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
833 if (yyn) goto yydefault;
834 #endif
836 yyerrpop: /* pop the current state because it cannot handle the error token */
838 if (yyssp == yyss) YYABORT;
839 yyvsp--;
840 yystate = *--yyssp;
842 yyerrhandle:
844 yyn = yypact[yystate];
845 if (yyn == YYFLAG)
846 goto yyerrdefault;
848 yyn += YYTERROR;
849 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
850 goto yyerrdefault;
852 yyn = yytable[yyn];
853 if (yyn < 0)
855 if (yyn == YYFLAG)
856 goto yyerrpop;
857 yyn = -yyn;
858 goto yyreduce;
860 else if (yyn == 0)
861 goto yyerrpop;
863 if (yyn == YYFINAL)
864 YYACCEPT;
866 *++yyvsp = yylval;
868 yystate = yyn;
869 goto yynewstate;
871 yyacceptlab:
872 /* YYACCEPT comes here. */
873 if (yyfree_stacks)
875 free (yyss);
876 free (yyvs);
878 return 0;
880 yyabortlab:
881 /* YYABORT comes here. */
882 if (yyfree_stacks)
884 free (yyss);
885 free (yyvs);
887 return 1;
890 Node *mainParse(const char *_code)
892 initFlex( _code );
893 top = nullptr;
894 yyparse();
895 deinitFlex();
897 if( top )
898 return top;
899 else
900 return nullptr;
903 void yyerror(const char * /*err*/)
905 // printf("REALKING ERR[%s]\n",err);
906 // if error, delete all nodes.
907 nodelist.clear();
908 top = nullptr;
911 #ifndef PARSE_DEBUG
912 int debug(const char * /*format*/, ...)
914 return 0;
916 #endif
918 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */