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 */
35 #include "grammar.hxx"
43 std::vector
<std::unique_ptr
<Node
>> nodelist
;
45 static void yyerror(const char *);
47 static Node
*top
=nullptr;
54 static int debug(const char *format
, ...);
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,
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,
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,
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,
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
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,
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,
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,
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,
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,
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,
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)
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. */
361 #define YYACCEPT goto yyacceptlab
362 #define YYABORT goto yyabortlab
367 #define YYLEX yylex()
373 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
375 #define YYLEX yylex(&yylval, &yylloc)
377 #else /* not YYLSP_NEEDED */
379 #define YYLEX yylex(&yylval, YYLEX_PARAM)
381 #define YYLEX yylex(&yylval)
383 #endif /* not YYLSP_NEEDED */
386 /* If nonreentrant, generate the variables here */
390 static int yychar
; /* the lookahead symbol */
391 YYSTYPE yylval
; /* the semantic value of the */
392 /* lookahead symbol */
395 YYLTYPE yylloc
; /* location data for the lookahead */
399 static int yynerrs
; /* number of parse errors so far */
400 #endif /* not YYPURE */
403 int yydebug
; /* nonzero means print parse trace */
404 /* Since this is uninitialized, it does not stop multiple parsers
408 /* YYINITDEPTH indicates the initial size of the parser's stacks */
411 #define YYINITDEPTH 200
414 /* YYMAXDEPTH is the maximum size the stacks can grow to
415 (effective only if the built-in stack extension method is used). */
422 #define YYMAXDEPTH 10000
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. */
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. */
442 int yyparse (void *);
444 static int yyparse();
449 yyparse(YYPARSE_PARAM_ARG
)
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 */
466 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
467 YYLTYPE
*yyls
= yylsa
;
470 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
473 int yystacksize
= YYINITDEPTH
;
474 int yyfree_stacks
= 0;
485 YYSTYPE yyval
; /* the variable used to return */
486 yyval
.dval
= nullptr;
487 /* semantic values from the action */
494 fprintf(stderr
, "Starting parse\n");
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. */
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. */
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
;
527 YYLTYPE
*yyls1
= yyls
;
530 /* Get the current used size of the three stacks, in elements. */
531 int size
= yyssp
- yyss
+ 1;
534 /* Each stack pointer address is followed by the size of
535 the data in use in that stack, in bytes. */
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
),
545 yyoverflow("parser stack overflow",
546 &yyss1
, size
* sizeof (*yyssp
),
547 &yyvs1
, size
* sizeof (*yyvsp
),
551 yyss
= yyss1
; yyvs
= yyvs1
;
555 #else /* no yyoverflow */
556 /* Extend the stack our own way. */
557 if (yystacksize
>= YYMAXDEPTH
)
559 yyerror("parser stack overflow");
571 if (yystacksize
> YYMAXDEPTH
)
572 yystacksize
= YYMAXDEPTH
;
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
));
579 yyls
= (YYLTYPE
*) malloc (yystacksize
* sizeof (*yylsp
));
580 memcpy ((char *)yyls
, (char *)yyls1
, size
* sizeof (*yylsp
));
582 #endif /* no yyoverflow */
584 yyssp
= yyss
+ size
- 1;
585 yyvsp
= yyvs
+ size
- 1;
587 yylsp
= yyls
+ size
- 1;
592 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
595 if (yyssp
>= yyss
+ yystacksize
- 1)
601 fprintf(stderr
, "Entering state %d\n", yystate
);
607 /* Do appropriate processing given the current state. */
608 /* Read a lookahead token if we need one and don't already have one. */
611 /* First try to decide what to do without reference to lookahead token. */
613 yyn
= yypact
[yystate
];
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
)
626 fprintf(stderr
, "Reading a token: ");
631 /* Convert token to internal form (in yychar1) for indexing tables with */
633 if (yychar
<= 0) /* This means end of input. */
636 yychar
= YYEOF
; /* Don't call YYLEX any more */
640 fprintf(stderr
, "Now at end of input.\n");
645 yychar1
= YYTRANSLATE(yychar
);
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. */
654 YYPRINT (stderr
, yychar
, yylval
);
656 fprintf (stderr
, ")\n");
662 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
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,
672 0, or most negative number => error. */
687 /* Shift the lookahead token. */
691 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
694 /* Discard the token being shifted unless it is eof. */
703 /* count tokens shifted since error; after three, turn off error status. */
704 if (yyerrstatus
) yyerrstatus
--;
709 /* Do the default action for the current state. */
712 yyn
= yydefact
[yystate
];
716 /* Do a reduction. yyn is the number of a rule to reduce with. */
720 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
727 fprintf (stderr
, "Reducing via rule %d (line %d), ",
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
]]);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
783 { yyval
.ptr
= new Node(ID_CHARACTER
); yyval
.ptr
->value
= strdup("|"); debug("Identifier : '|'\n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
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
);
792 { yyval
.ptr
= new Node(ID_PRIMARYEXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("PrimaryExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
798 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
= strdup("("); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
801 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
= strdup("["); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
804 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
= strdup("{"); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
807 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
= strdup("<"); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
810 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
= strdup("|"); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
813 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
=strdup("||"); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
816 { yyval
.ptr
= new Node(ID_LEFT
); yyval
.ptr
->value
= strdup(yyvsp
[0].str
); debug("EQLeft \n"); nodelist
.emplace_back(yyval
.ptr
);
819 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
= strdup(")"); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
822 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
= strdup("]"); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
825 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
= strdup("}"); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
828 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
= strdup(">"); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
831 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
= strdup("|"); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
834 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
= strdup("||"); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
837 { yyval
.ptr
= new Node(ID_RIGHT
); yyval
.ptr
->value
= strdup(yyvsp
[0].str
); debug("EQRight \n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
843 { yyval
.ptr
= new Node(ID_PARENTH
); yyval
.ptr
->child
= yyvsp
[-1].ptr
; debug("Parenth: '(' ExprList ')' \n"); nodelist
.emplace_back(yyval
.ptr
);
846 { yyval
.ptr
= new Node(ID_PARENTH
); debug("Parenth: '(' ')' \n"); nodelist
.emplace_back(yyval
.ptr
);
849 { yyval
.ptr
= new Node(ID_BLOCK
); yyval
.ptr
->child
= yyvsp
[-1].ptr
; debug("Block: '{' ExprList '}' \n"); nodelist
.emplace_back(yyval
.ptr
);
852 { yyval
.ptr
= new Node(ID_BLOCK
); debug("Block: '{' '}' \n"); nodelist
.emplace_back(yyval
.ptr
);
855 { yyval
.ptr
= new Node(ID_BRACKET
); yyval
.ptr
->child
= yyvsp
[-1].ptr
; debug("Bracket \n"); nodelist
.emplace_back(yyval
.ptr
);
858 { yyval
.ptr
= new Node(ID_BRACKET
); debug("Bracket \n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
894 { yyval
.ptr
= new Node(ID_BEGIN
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("BeginExpr\n");
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");
900 { yyval
.ptr
= new Node(ID_END
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("EndExpr\n");
903 { yyval
.ptr
= new Node(ID_MATHML
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); top
= yyval
.ptr
; debug("MathML\n");
906 { yyval
.ptr
= new Node(ID_LINES
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("Lines\n");
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");
912 { yyval
.ptr
= new Node(ID_LINE
); yyval
.ptr
->child
= yyvsp
[0].ptr
; nodelist
.emplace_back(yyval
.ptr
); debug("Line\n");
915 { yyval
.ptr
= new Node(ID_EXPRLIST
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("ExprList : Expr\n"); nodelist
.emplace_back(yyval
.ptr
);
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
);
921 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : Block\n"); nodelist
.emplace_back(yyval
.ptr
);
924 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : Parenth\n"); nodelist
.emplace_back(yyval
.ptr
);
927 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : Fence\n"); nodelist
.emplace_back(yyval
.ptr
);
930 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : SubSupExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
933 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : FractionExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
936 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : OverExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
939 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : DecorationExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
942 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : RootExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
945 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : AccentExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
948 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : PrimaryExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
951 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : BeginExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
954 { yyval
.ptr
= new Node(ID_EXPR
); yyval
.ptr
->child
= yyvsp
[0].ptr
; debug("Expr : EndExpr\n"); nodelist
.emplace_back(yyval
.ptr
);
957 /* the action file gets copied in place of this dollarsign */
968 short *ssp1
= yyss
- 1;
969 fprintf (stderr
, "state stack now");
970 while (ssp1
!= yyssp
)
971 fprintf (stderr
, " %d", *++ssp1
);
972 fprintf (stderr
, "\n");
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
;
990 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
991 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
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. */
1002 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1003 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1004 yystate
= yytable
[yystate
];
1006 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1010 yyerrlab
: /* here on detecting error */
1013 /* If not already recovering from an error, report this error. */
1017 #ifdef YYERROR_VERBOSE
1018 yyn
= yypact
[yystate
];
1020 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
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);
1035 strcpy(msg
, "parse error");
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
]);
1054 yyerror ("parse error; also virtual memory exceeded");
1057 #endif /* YYERROR_VERBOSE */
1058 yyerror("parse error");
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
)
1074 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1080 /* Else will try to reuse lookahead token
1081 after shifting the error token. */
1083 yyerrstatus
= 3; /* Each real token shifted decrements this */
1087 yyerrdefault
: /* current state does not do anything special for the error token. */
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
;
1096 yyerrpop
: /* pop the current state because it cannot handle the error token */
1098 if (yyssp
== yyss
) YYABORT
;
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");
1118 yyn
= yypact
[yystate
];
1123 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1142 fprintf(stderr
, "Shifting error token, ");
1154 /* YYACCEPT comes here. */
1166 /* YYABORT comes here. */
1179 Node
*mainParse(const char *_code
)
1190 void yyerror(const char * /*err*/)
1192 // printf("REALKING ERR[%s]\n",err);
1193 // if error, delete all nodes.
1199 int debug(const char * /*format*/, ...)
1205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */