1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 */
32 #include "grammar.hxx"
40 std::vector
<std::unique_ptr
<Node
>> nodelist
;
42 static void yyerror(const char *);
44 static Node
*top
=nullptr;
51 static int debug(const char *format
, ...);
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,
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,
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,
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,
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,
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,
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,
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)
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. */
294 #define YYACCEPT goto yyacceptlab
295 #define YYABORT goto yyabortlab
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 */
312 #define YYINITDEPTH 200
315 /* YYMAXDEPTH is the maximum size the stacks can grow to
316 (effective only if the built-in stack extension method is used). */
323 #define YYMAXDEPTH 10000
326 #define YYPARSE_PARAM_ARG
327 #define YYPARSE_PARAM_DECL
329 /* Prevent warning if -Wstrict-prototypes. */
331 static int yyparse();
335 yyparse(YYPARSE_PARAM_ARG
)
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 */
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. */
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. */
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
;
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");
403 if (yystacksize
> YYMAXDEPTH
)
404 yystacksize
= YYMAXDEPTH
;
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
417 yyssp
= yyss
+ size
- 1;
418 yyvsp
= yyvs
+ size
- 1;
420 if (yyssp
>= yyss
+ yystacksize
- 1)
427 /* Do appropriate processing given the current state. */
428 /* Read a lookahead token if we need one and don't already have one. */
431 /* First try to decide what to do without reference to lookahead token. */
433 yyn
= yypact
[yystate
];
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
)
447 /* Convert token to internal form (in yychar1) for indexing tables with */
449 if (yychar
<= 0) /* This means end of input. */
452 yychar
= YYEOF
; /* Don't call YYLEX any more */
457 yychar1
= YYTRANSLATE(yychar
);
462 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
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,
472 0, or most negative number => error. */
487 /* Shift the lookahead token. */
489 /* Discard the token being shifted unless it is eof. */
495 /* count tokens shifted since error; after three, turn off error status. */
496 if (yyerrstatus
) yyerrstatus
--;
501 /* Do the default action for the current state. */
504 yyn
= yydefact
[yystate
];
508 /* Do a reduction. yyn is the number of a rule to reduce with. */
512 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
559 { yyval
.ptr
= new Node(ID_CHARACTER
); yyval
.ptr
->value
.reset(strdup("|")); debug("Identifier : '|'\n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
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
);
568 { yyval
.ptr
= new Node(ID_PRIMARYEXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("PrimaryExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
574 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
.reset(strdup("(")); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
577 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
.reset(strdup("[")); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
580 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
.reset(strdup("{")); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
583 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
.reset(strdup("<")); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
586 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
.reset(strdup("|")); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
589 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
.reset(strdup("||")); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
592 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
.reset(strdup(yyvsp
[0].str
)); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
595 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
.reset(strdup(")")); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
598 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
.reset(strdup("]")); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
601 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
.reset(strdup("}")); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
604 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
.reset(strdup(">")); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
607 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
.reset(strdup("|")); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
610 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
.reset(strdup("||")); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
613 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
.reset(strdup(yyvsp
[0].str
)); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
619 { yyval
.ptr
= new Node(ID_PARENTH
); yyval
.ptr
->child
= yyvsp
[-1].ptr
; debug("Parenth: '(' ExprList ')' \n"); nodelist
.emplace_back(yyval
.ptr
);
622 { yyval
.ptr
= new Node(ID_PARENTH
); debug("Parenth: '(' ')' \n"); nodelist
.emplace_back(yyval
.ptr
);
625 { yyval
.ptr
= new Node(ID_BLOCK
); yyval
.ptr
->child
= yyvsp
[-1].ptr
; debug("Block: '{' ExprList '}' \n"); nodelist
.emplace_back(yyval
.ptr
);
628 { yyval
.ptr
= new Node(ID_BLOCK
); debug("Block: '{' '}' \n"); nodelist
.emplace_back(yyval
.ptr
);
631 { yyval
.ptr
= new Node(ID_BRACKET
); yyval
.ptr
->child
= yyvsp
[-1].ptr
; debug("Bracket \n"); nodelist
.emplace_back(yyval
.ptr
);
634 { yyval
.ptr
= new Node(ID_BRACKET
); debug("Bracket \n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
670 { yyval
.ptr
= new Node(ID_BEGIN
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("BeginExpr\n");
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");
676 { yyval
.ptr
= new Node(ID_END
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("EndExpr\n");
679 { yyval
.ptr
= new Node(ID_MATHML
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); top
= yyval
.ptr
; debug("MathML\n");
682 { yyval
.ptr
= new Node(ID_LINES
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("Lines\n");
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");
688 { yyval
.ptr
= new Node(ID_LINE
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("Line\n");
691 { yyval
.ptr
= new Node(ID_EXPRLIST
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("ExprList : Expr\n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
697 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : Block\n"); nodelist
.emplace_back(yyval
.ptr
);
700 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : Parenth\n"); nodelist
.emplace_back(yyval
.ptr
);
703 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : Fence\n"); nodelist
.emplace_back(yyval
.ptr
);
706 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : SubSupExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
709 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : FractionExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
712 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : OverExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
715 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : DecorationExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
718 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : RootExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
721 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : AccentExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
724 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : PrimaryExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
727 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : BeginExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
730 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : EndExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
733 /* the action file gets copied in place of this dollarsign */
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. */
747 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
748 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
749 yystate
= yytable
[yystate
];
751 yystate
= yydefgoto
[yyn
- YYNTBASE
];
755 yyerrlab
: /* here on detecting error */
758 /* If not already recovering from an error, report this error. */
762 #ifdef YYERROR_VERBOSE
763 yyn
= yypact
[yystate
];
765 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
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);
780 strcpy(msg
, "parse error");
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
]);
799 yyerror ("parse error; also virtual memory exceeded");
802 #endif /* YYERROR_VERBOSE */
803 yyerror("parse error");
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 */
820 /* Else will try to reuse lookahead token
821 after shifting the error token. */
823 yyerrstatus
= 3; /* Each real token shifted decrements this */
827 yyerrdefault
: /* current state does not do anything special for the error token. */
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
;
836 yyerrpop
: /* pop the current state because it cannot handle the error token */
838 if (yyssp
== yyss
) YYABORT
;
844 yyn
= yypact
[yystate
];
849 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
872 /* YYACCEPT comes here. */
881 /* YYABORT comes here. */
890 Node
*mainParse(const char *_code
)
903 void yyerror(const char * /*err*/)
905 // printf("REALKING ERR[%s]\n",err);
906 // if error, delete all nodes.
912 int debug(const char * /*format*/, ...)
918 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */