Line data Source code
1 : /* A Bison parser, made by GNU Bison 3.0.4. */
2 :
3 : /* Bison implementation for Yacc-like parsers in C
4 :
5 : Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6 :
7 : This program is free software: you can redistribute it and/or modify
8 : it under the terms of the GNU General Public License as published by
9 : the Free Software Foundation, either version 3 of the License, or
10 : (at your option) any later version.
11 :
12 : This program is distributed in the hope that it will be useful,
13 : but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : GNU General Public License for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 :
20 : /* As a special exception, you may create a larger work that contains
21 : part or all of the Bison parser skeleton and distribute that work
22 : under terms of your choice, so long as that work isn't itself a
23 : parser generator using the skeleton or a modified version thereof
24 : as a parser skeleton. Alternatively, if you modify or redistribute
25 : the parser skeleton itself, you may (at your option) remove this
26 : special exception, which will cause the skeleton and the resulting
27 : Bison output files to be licensed under the GNU General Public
28 : License without this special exception.
29 :
30 : This special exception was added by the Free Software Foundation in
31 : version 2.2 of Bison. */
32 :
33 : /* C LALR(1) parser skeleton written by Richard Stallman, by
34 : simplifying the original so-called "semantic" parser. */
35 :
36 : /* All symbols defined below should begin with yy or YY, to avoid
37 : infringing on user name space. This should be done even for local
38 : variables, as they might otherwise be expanded by user macros.
39 : There are some unavoidable exceptions within include files to
40 : define necessary library symbols; they are noted "INFRINGES ON
41 : USER NAME SPACE" below. */
42 :
43 : /* Identify Bison output. */
44 : #define YYBISON 1
45 :
46 : /* Bison version. */
47 : #define YYBISON_VERSION "3.0.4"
48 :
49 : /* Skeleton name. */
50 : #define YYSKELETON_NAME "yacc.c"
51 :
52 : /* Pure parsers. */
53 : #define YYPURE 1
54 :
55 : /* Push parsers. */
56 : #define YYPUSH 0
57 :
58 : /* Pull parsers. */
59 : #define YYPULL 1
60 :
61 :
62 : /* Substitute the variable and function names. */
63 : #define yyparse ppparse
64 : #define yylex pplex
65 : #define yyerror pperror
66 : #define yydebug ppdebug
67 : #define yynerrs ppnerrs
68 :
69 :
70 : /* Copy the first part of user declarations. */
71 :
72 :
73 : //
74 : // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
75 : // Use of this source code is governed by a BSD-style license that can be
76 : // found in the LICENSE file.
77 : //
78 :
79 : // This file is auto-generated by generate_parser.sh. DO NOT EDIT!
80 :
81 : #if defined(__GNUC__)
82 : // Triggered by the auto-generated pplval variable.
83 : #if !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
84 : #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
85 : #else
86 : #pragma GCC diagnostic ignored "-Wuninitialized"
87 : #endif
88 : #elif defined(_MSC_VER)
89 : #pragma warning(disable: 4065 4244 4701 4702)
90 : #endif
91 :
92 : #include "ExpressionParser.h"
93 :
94 : #if defined(_MSC_VER)
95 : #include <malloc.h>
96 : #else
97 : #include <stdlib.h>
98 : #endif
99 :
100 : #include <cassert>
101 : #include <sstream>
102 : #include <stdint.h>
103 :
104 : #include "DiagnosticsBase.h"
105 : #include "Lexer.h"
106 : #include "Token.h"
107 : #include "common/mathutil.h"
108 :
109 : typedef int32_t YYSTYPE;
110 : typedef uint32_t UNSIGNED_TYPE;
111 :
112 : #define YYENABLE_NLS 0
113 : #define YYLTYPE_IS_TRIVIAL 1
114 : #define YYSTYPE_IS_TRIVIAL 1
115 : #define YYSTYPE_IS_DECLARED 1
116 :
117 : namespace {
118 : struct Context
119 : {
120 : pp::Diagnostics* diagnostics;
121 : pp::Lexer* lexer;
122 : pp::Token* token;
123 : int* result;
124 : bool parsePresetToken;
125 :
126 : pp::ExpressionParser::ErrorSettings errorSettings;
127 : bool *valid;
128 :
129 0 : void startIgnoreErrors() { ++ignoreErrors; }
130 0 : void endIgnoreErrors() { --ignoreErrors; }
131 :
132 0 : bool isIgnoringErrors() { return ignoreErrors > 0; }
133 :
134 : int ignoreErrors;
135 : };
136 : } // namespace
137 :
138 :
139 : static int yylex(YYSTYPE* lvalp, Context* context);
140 : static void yyerror(Context* context, const char* reason);
141 :
142 :
143 :
144 : # ifndef YY_NULLPTR
145 : # if defined __cplusplus && 201103L <= __cplusplus
146 : # define YY_NULLPTR nullptr
147 : # else
148 : # define YY_NULLPTR 0
149 : # endif
150 : # endif
151 :
152 : /* Enabling verbose error messages. */
153 : #ifdef YYERROR_VERBOSE
154 : # undef YYERROR_VERBOSE
155 : # define YYERROR_VERBOSE 1
156 : #else
157 : # define YYERROR_VERBOSE 0
158 : #endif
159 :
160 :
161 : /* Debug traces. */
162 : #ifndef YYDEBUG
163 : # define YYDEBUG 0
164 : #endif
165 : #if YYDEBUG
166 : extern int ppdebug;
167 : #endif
168 :
169 : /* Token type. */
170 : #ifndef YYTOKENTYPE
171 : # define YYTOKENTYPE
172 : enum yytokentype
173 : {
174 : TOK_CONST_INT = 258,
175 : TOK_IDENTIFIER = 259,
176 : TOK_OP_OR = 260,
177 : TOK_OP_AND = 261,
178 : TOK_OP_EQ = 262,
179 : TOK_OP_NE = 263,
180 : TOK_OP_LE = 264,
181 : TOK_OP_GE = 265,
182 : TOK_OP_LEFT = 266,
183 : TOK_OP_RIGHT = 267,
184 : TOK_UNARY = 268
185 : };
186 : #endif
187 :
188 : /* Value type. */
189 : #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
190 : typedef int YYSTYPE;
191 : # define YYSTYPE_IS_TRIVIAL 1
192 : # define YYSTYPE_IS_DECLARED 1
193 : #endif
194 :
195 :
196 :
197 : int ppparse (Context *context);
198 :
199 :
200 :
201 : /* Copy the second part of user declarations. */
202 :
203 :
204 :
205 : #ifdef short
206 : # undef short
207 : #endif
208 :
209 : #ifdef YYTYPE_UINT8
210 : typedef YYTYPE_UINT8 yytype_uint8;
211 : #else
212 : typedef unsigned char yytype_uint8;
213 : #endif
214 :
215 : #ifdef YYTYPE_INT8
216 : typedef YYTYPE_INT8 yytype_int8;
217 : #else
218 : typedef signed char yytype_int8;
219 : #endif
220 :
221 : #ifdef YYTYPE_UINT16
222 : typedef YYTYPE_UINT16 yytype_uint16;
223 : #else
224 : typedef unsigned short int yytype_uint16;
225 : #endif
226 :
227 : #ifdef YYTYPE_INT16
228 : typedef YYTYPE_INT16 yytype_int16;
229 : #else
230 : typedef short int yytype_int16;
231 : #endif
232 :
233 : #ifndef YYSIZE_T
234 : # ifdef __SIZE_TYPE__
235 : # define YYSIZE_T __SIZE_TYPE__
236 : # elif defined size_t
237 : # define YYSIZE_T size_t
238 : # elif ! defined YYSIZE_T
239 : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
240 : # define YYSIZE_T size_t
241 : # else
242 : # define YYSIZE_T unsigned int
243 : # endif
244 : #endif
245 :
246 : #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
247 :
248 : #ifndef YY_
249 : # if defined YYENABLE_NLS && YYENABLE_NLS
250 : # if ENABLE_NLS
251 : # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
252 : # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
253 : # endif
254 : # endif
255 : # ifndef YY_
256 : # define YY_(Msgid) Msgid
257 : # endif
258 : #endif
259 :
260 : #ifndef YY_ATTRIBUTE
261 : # if (defined __GNUC__ \
262 : && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
263 : || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
264 : # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
265 : # else
266 : # define YY_ATTRIBUTE(Spec) /* empty */
267 : # endif
268 : #endif
269 :
270 : #ifndef YY_ATTRIBUTE_PURE
271 : # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
272 : #endif
273 :
274 : #ifndef YY_ATTRIBUTE_UNUSED
275 : # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
276 : #endif
277 :
278 : #if !defined _Noreturn \
279 : && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
280 : # if defined _MSC_VER && 1200 <= _MSC_VER
281 : # define _Noreturn __declspec (noreturn)
282 : # else
283 : # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
284 : # endif
285 : #endif
286 :
287 : /* Suppress unused-variable warnings by "using" E. */
288 : #if ! defined lint || defined __GNUC__
289 : # define YYUSE(E) ((void) (E))
290 : #else
291 : # define YYUSE(E) /* empty */
292 : #endif
293 :
294 : #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
295 : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
296 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
297 : _Pragma ("GCC diagnostic push") \
298 : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
299 : _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
300 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
301 : _Pragma ("GCC diagnostic pop")
302 : #else
303 : # define YY_INITIAL_VALUE(Value) Value
304 : #endif
305 : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
306 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
307 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
308 : #endif
309 : #ifndef YY_INITIAL_VALUE
310 : # define YY_INITIAL_VALUE(Value) /* Nothing. */
311 : #endif
312 :
313 :
314 : #if ! defined yyoverflow || YYERROR_VERBOSE
315 :
316 : /* The parser invokes alloca or malloc; define the necessary symbols. */
317 :
318 : # ifdef YYSTACK_USE_ALLOCA
319 : # if YYSTACK_USE_ALLOCA
320 : # ifdef __GNUC__
321 : # define YYSTACK_ALLOC __builtin_alloca
322 : # elif defined __BUILTIN_VA_ARG_INCR
323 : # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
324 : # elif defined _AIX
325 : # define YYSTACK_ALLOC __alloca
326 : # elif defined _MSC_VER
327 : # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
328 : # define alloca _alloca
329 : # else
330 : # define YYSTACK_ALLOC alloca
331 : # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
332 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
333 : /* Use EXIT_SUCCESS as a witness for stdlib.h. */
334 : # ifndef EXIT_SUCCESS
335 : # define EXIT_SUCCESS 0
336 : # endif
337 : # endif
338 : # endif
339 : # endif
340 : # endif
341 :
342 : # ifdef YYSTACK_ALLOC
343 : /* Pacify GCC's 'empty if-body' warning. */
344 : # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
345 : # ifndef YYSTACK_ALLOC_MAXIMUM
346 : /* The OS might guarantee only one guard page at the bottom of the stack,
347 : and a page size can be as small as 4096 bytes. So we cannot safely
348 : invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
349 : to allow for a few compiler-allocated temporary stack slots. */
350 : # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
351 : # endif
352 : # else
353 : # define YYSTACK_ALLOC YYMALLOC
354 : # define YYSTACK_FREE YYFREE
355 : # ifndef YYSTACK_ALLOC_MAXIMUM
356 : # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
357 : # endif
358 : # if (defined __cplusplus && ! defined EXIT_SUCCESS \
359 : && ! ((defined YYMALLOC || defined malloc) \
360 : && (defined YYFREE || defined free)))
361 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
362 : # ifndef EXIT_SUCCESS
363 : # define EXIT_SUCCESS 0
364 : # endif
365 : # endif
366 : # ifndef YYMALLOC
367 : # define YYMALLOC malloc
368 : # if ! defined malloc && ! defined EXIT_SUCCESS
369 : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
370 : # endif
371 : # endif
372 : # ifndef YYFREE
373 : # define YYFREE free
374 : # if ! defined free && ! defined EXIT_SUCCESS
375 : void free (void *); /* INFRINGES ON USER NAME SPACE */
376 : # endif
377 : # endif
378 : # endif
379 : #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
380 :
381 :
382 : #if (! defined yyoverflow \
383 : && (! defined __cplusplus \
384 : || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
385 :
386 : /* A type that is properly aligned for any stack member. */
387 : union yyalloc
388 : {
389 : yytype_int16 yyss_alloc;
390 : YYSTYPE yyvs_alloc;
391 : };
392 :
393 : /* The size of the maximum gap between one aligned stack and the next. */
394 : # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
395 :
396 : /* The size of an array large to enough to hold all stacks, each with
397 : N elements. */
398 : # define YYSTACK_BYTES(N) \
399 : ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
400 : + YYSTACK_GAP_MAXIMUM)
401 :
402 : # define YYCOPY_NEEDED 1
403 :
404 : /* Relocate STACK from its old location to the new one. The
405 : local variables YYSIZE and YYSTACKSIZE give the old and new number of
406 : elements in the stack, and YYPTR gives the new location of the
407 : stack. Advance YYPTR to a properly aligned location for the next
408 : stack. */
409 : # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
410 : do \
411 : { \
412 : YYSIZE_T yynewbytes; \
413 : YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
414 : Stack = &yyptr->Stack_alloc; \
415 : yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
416 : yyptr += yynewbytes / sizeof (*yyptr); \
417 : } \
418 : while (0)
419 :
420 : #endif
421 :
422 : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
423 : /* Copy COUNT objects from SRC to DST. The source and destination do
424 : not overlap. */
425 : # ifndef YYCOPY
426 : # if defined __GNUC__ && 1 < __GNUC__
427 : # define YYCOPY(Dst, Src, Count) \
428 : __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
429 : # else
430 : # define YYCOPY(Dst, Src, Count) \
431 : do \
432 : { \
433 : YYSIZE_T yyi; \
434 : for (yyi = 0; yyi < (Count); yyi++) \
435 : (Dst)[yyi] = (Src)[yyi]; \
436 : } \
437 : while (0)
438 : # endif
439 : # endif
440 : #endif /* !YYCOPY_NEEDED */
441 :
442 : /* YYFINAL -- State number of the termination state. */
443 : #define YYFINAL 15
444 : /* YYLAST -- Last index in YYTABLE. */
445 : #define YYLAST 176
446 :
447 : /* YYNTOKENS -- Number of terminals. */
448 : #define YYNTOKENS 28
449 : /* YYNNTS -- Number of nonterminals. */
450 : #define YYNNTS 5
451 : /* YYNRULES -- Number of rules. */
452 : #define YYNRULES 29
453 : /* YYNSTATES -- Number of states. */
454 : #define YYNSTATES 55
455 :
456 : /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
457 : by yylex, with out-of-bounds checking. */
458 : #define YYUNDEFTOK 2
459 : #define YYMAXUTOK 268
460 :
461 : #define YYTRANSLATE(YYX) \
462 : ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
463 :
464 : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
465 : as returned by yylex, without out-of-bounds checking. */
466 : static const yytype_uint8 yytranslate[] =
467 : {
468 : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 : 2, 2, 2, 24, 2, 2, 2, 22, 9, 2,
472 : 26, 27, 20, 18, 2, 19, 2, 21, 2, 2,
473 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 : 12, 2, 13, 2, 2, 2, 2, 2, 2, 2,
475 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
477 : 2, 2, 2, 2, 8, 2, 2, 2, 2, 2,
478 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
479 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 : 2, 2, 2, 2, 7, 2, 25, 2, 2, 2,
481 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
483 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
484 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
485 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
486 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
490 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
492 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 : 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
494 : 5, 6, 10, 11, 14, 15, 16, 17, 23
495 : };
496 :
497 : #if YYDEBUG
498 : /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
499 : static const yytype_uint16 yyrline[] =
500 : {
501 : 0, 108, 108, 115, 116, 127, 127, 148, 148, 169,
502 : 172, 175, 178, 181, 184, 187, 190, 193, 196, 221,
503 : 246, 249, 252, 278, 305, 308, 311, 314, 326, 329
504 : };
505 : #endif
506 :
507 : #if YYDEBUG || YYERROR_VERBOSE || 0
508 : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
509 : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
510 : static const char *const yytname[] =
511 : {
512 : "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_IDENTIFIER",
513 : "TOK_OP_OR", "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_EQ", "TOK_OP_NE",
514 : "'<'", "'>'", "TOK_OP_LE", "TOK_OP_GE", "TOK_OP_LEFT", "TOK_OP_RIGHT",
515 : "'+'", "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('",
516 : "')'", "$accept", "input", "expression", "$@1", "$@2", YY_NULLPTR
517 : };
518 : #endif
519 :
520 : # ifdef YYPRINT
521 : /* YYTOKNUM[NUM] -- (External) token number corresponding to the
522 : (internal) symbol number NUM (which must be that of a token). */
523 : static const yytype_uint16 yytoknum[] =
524 : {
525 : 0, 256, 257, 258, 259, 260, 261, 124, 94, 38,
526 : 262, 263, 60, 62, 264, 265, 266, 267, 43, 45,
527 : 42, 47, 37, 268, 33, 126, 40, 41
528 : };
529 : # endif
530 :
531 : #define YYPACT_NINF -12
532 :
533 : #define yypact_value_is_default(Yystate) \
534 : (!!((Yystate) == (-12)))
535 :
536 : #define YYTABLE_NINF -1
537 :
538 : #define yytable_value_is_error(Yytable_value) \
539 : 0
540 :
541 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
542 : STATE-NUM. */
543 : static const yytype_int16 yypact[] =
544 : {
545 : 31, -12, -12, 31, 31, 31, 31, 31, 51, 76,
546 : -12, -12, -12, -12, 53, -12, -12, -12, 31, 31,
547 : 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
548 : 31, 31, 31, 31, -12, 31, 31, 124, 138, 26,
549 : 149, 149, -11, -11, -11, -11, 154, 154, -8, -8,
550 : -12, -12, -12, 93, 109
551 : };
552 :
553 : /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
554 : Performed when YYTABLE does not specify something else to do. Zero
555 : means the default is an error. */
556 : static const yytype_uint8 yydefact[] =
557 : {
558 : 0, 3, 4, 0, 0, 0, 0, 0, 0, 2,
559 : 28, 27, 25, 26, 0, 1, 5, 7, 0, 0,
560 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
561 : 0, 0, 0, 0, 29, 0, 0, 9, 10, 11,
562 : 13, 12, 17, 16, 15, 14, 19, 18, 21, 20,
563 : 24, 23, 22, 6, 8
564 : };
565 :
566 : /* YYPGOTO[NTERM-NUM]. */
567 : static const yytype_int8 yypgoto[] =
568 : {
569 : -12, -12, -3, -12, -12
570 : };
571 :
572 : /* YYDEFGOTO[NTERM-NUM]. */
573 : static const yytype_int8 yydefgoto[] =
574 : {
575 : -1, 8, 9, 35, 36
576 : };
577 :
578 : /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
579 : positive, shift that token. If negative, reduce the rule whose
580 : number is the opposite. If YYTABLE_NINF, syntax error. */
581 : static const yytype_uint8 yytable[] =
582 : {
583 : 10, 11, 12, 13, 14, 27, 28, 29, 30, 31,
584 : 32, 33, 31, 32, 33, 37, 38, 39, 40, 41,
585 : 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
586 : 52, 0, 53, 54, 1, 2, 21, 22, 23, 24,
587 : 25, 26, 27, 28, 29, 30, 31, 32, 33, 3,
588 : 4, 15, 0, 0, 0, 5, 6, 7, 16, 17,
589 : 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
590 : 28, 29, 30, 31, 32, 33, 0, 0, 0, 0,
591 : 34, 16, 17, 18, 19, 20, 21, 22, 23, 24,
592 : 25, 26, 27, 28, 29, 30, 31, 32, 33, 17,
593 : 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
594 : 28, 29, 30, 31, 32, 33, 18, 19, 20, 21,
595 : 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
596 : 32, 33, 19, 20, 21, 22, 23, 24, 25, 26,
597 : 27, 28, 29, 30, 31, 32, 33, 20, 21, 22,
598 : 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
599 : 33, 23, 24, 25, 26, 27, 28, 29, 30, 31,
600 : 32, 33, 29, 30, 31, 32, 33
601 : };
602 :
603 : static const yytype_int8 yycheck[] =
604 : {
605 : 3, 4, 5, 6, 7, 16, 17, 18, 19, 20,
606 : 21, 22, 20, 21, 22, 18, 19, 20, 21, 22,
607 : 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
608 : 33, -1, 35, 36, 3, 4, 10, 11, 12, 13,
609 : 14, 15, 16, 17, 18, 19, 20, 21, 22, 18,
610 : 19, 0, -1, -1, -1, 24, 25, 26, 5, 6,
611 : 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
612 : 17, 18, 19, 20, 21, 22, -1, -1, -1, -1,
613 : 27, 5, 6, 7, 8, 9, 10, 11, 12, 13,
614 : 14, 15, 16, 17, 18, 19, 20, 21, 22, 6,
615 : 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
616 : 17, 18, 19, 20, 21, 22, 7, 8, 9, 10,
617 : 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
618 : 21, 22, 8, 9, 10, 11, 12, 13, 14, 15,
619 : 16, 17, 18, 19, 20, 21, 22, 9, 10, 11,
620 : 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
621 : 22, 12, 13, 14, 15, 16, 17, 18, 19, 20,
622 : 21, 22, 18, 19, 20, 21, 22
623 : };
624 :
625 : /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
626 : symbol of state STATE-NUM. */
627 : static const yytype_uint8 yystos[] =
628 : {
629 : 0, 3, 4, 18, 19, 24, 25, 26, 29, 30,
630 : 30, 30, 30, 30, 30, 0, 5, 6, 7, 8,
631 : 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
632 : 19, 20, 21, 22, 27, 31, 32, 30, 30, 30,
633 : 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
634 : 30, 30, 30, 30, 30
635 : };
636 :
637 : /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
638 : static const yytype_uint8 yyr1[] =
639 : {
640 : 0, 28, 29, 30, 30, 31, 30, 32, 30, 30,
641 : 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
642 : 30, 30, 30, 30, 30, 30, 30, 30, 30, 30
643 : };
644 :
645 : /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
646 : static const yytype_uint8 yyr2[] =
647 : {
648 : 0, 2, 1, 1, 1, 0, 4, 0, 4, 3,
649 : 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
650 : 3, 3, 3, 3, 3, 2, 2, 2, 2, 3
651 : };
652 :
653 :
654 : #define yyerrok (yyerrstatus = 0)
655 : #define yyclearin (yychar = YYEMPTY)
656 : #define YYEMPTY (-2)
657 : #define YYEOF 0
658 :
659 : #define YYACCEPT goto yyacceptlab
660 : #define YYABORT goto yyabortlab
661 : #define YYERROR goto yyerrorlab
662 :
663 :
664 : #define YYRECOVERING() (!!yyerrstatus)
665 :
666 : #define YYBACKUP(Token, Value) \
667 : do \
668 : if (yychar == YYEMPTY) \
669 : { \
670 : yychar = (Token); \
671 : yylval = (Value); \
672 : YYPOPSTACK (yylen); \
673 : yystate = *yyssp; \
674 : goto yybackup; \
675 : } \
676 : else \
677 : { \
678 : yyerror (context, YY_("syntax error: cannot back up")); \
679 : YYERROR; \
680 : } \
681 : while (0)
682 :
683 : /* Error token number */
684 : #define YYTERROR 1
685 : #define YYERRCODE 256
686 :
687 :
688 :
689 : /* Enable debugging if requested. */
690 : #if YYDEBUG
691 :
692 : # ifndef YYFPRINTF
693 : # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
694 : # define YYFPRINTF fprintf
695 : # endif
696 :
697 : # define YYDPRINTF(Args) \
698 : do { \
699 : if (yydebug) \
700 : YYFPRINTF Args; \
701 : } while (0)
702 :
703 : /* This macro is provided for backward compatibility. */
704 : #ifndef YY_LOCATION_PRINT
705 : # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
706 : #endif
707 :
708 :
709 : # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
710 : do { \
711 : if (yydebug) \
712 : { \
713 : YYFPRINTF (stderr, "%s ", Title); \
714 : yy_symbol_print (stderr, \
715 : Type, Value, context); \
716 : YYFPRINTF (stderr, "\n"); \
717 : } \
718 : } while (0)
719 :
720 :
721 : /*----------------------------------------.
722 : | Print this symbol's value on YYOUTPUT. |
723 : `----------------------------------------*/
724 :
725 : static void
726 : yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
727 : {
728 : FILE *yyo = yyoutput;
729 : YYUSE (yyo);
730 : YYUSE (context);
731 : if (!yyvaluep)
732 : return;
733 : # ifdef YYPRINT
734 : if (yytype < YYNTOKENS)
735 : YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
736 : # endif
737 : YYUSE (yytype);
738 : }
739 :
740 :
741 : /*--------------------------------.
742 : | Print this symbol on YYOUTPUT. |
743 : `--------------------------------*/
744 :
745 : static void
746 : yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
747 : {
748 : YYFPRINTF (yyoutput, "%s %s (",
749 : yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
750 :
751 : yy_symbol_value_print (yyoutput, yytype, yyvaluep, context);
752 : YYFPRINTF (yyoutput, ")");
753 : }
754 :
755 : /*------------------------------------------------------------------.
756 : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
757 : | TOP (included). |
758 : `------------------------------------------------------------------*/
759 :
760 : static void
761 : yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
762 : {
763 : YYFPRINTF (stderr, "Stack now");
764 : for (; yybottom <= yytop; yybottom++)
765 : {
766 : int yybot = *yybottom;
767 : YYFPRINTF (stderr, " %d", yybot);
768 : }
769 : YYFPRINTF (stderr, "\n");
770 : }
771 :
772 : # define YY_STACK_PRINT(Bottom, Top) \
773 : do { \
774 : if (yydebug) \
775 : yy_stack_print ((Bottom), (Top)); \
776 : } while (0)
777 :
778 :
779 : /*------------------------------------------------.
780 : | Report that the YYRULE is going to be reduced. |
781 : `------------------------------------------------*/
782 :
783 : static void
784 : yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, Context *context)
785 : {
786 : unsigned long int yylno = yyrline[yyrule];
787 : int yynrhs = yyr2[yyrule];
788 : int yyi;
789 : YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
790 : yyrule - 1, yylno);
791 : /* The symbols being reduced. */
792 : for (yyi = 0; yyi < yynrhs; yyi++)
793 : {
794 : YYFPRINTF (stderr, " $%d = ", yyi + 1);
795 : yy_symbol_print (stderr,
796 : yystos[yyssp[yyi + 1 - yynrhs]],
797 : &(yyvsp[(yyi + 1) - (yynrhs)])
798 : , context);
799 : YYFPRINTF (stderr, "\n");
800 : }
801 : }
802 :
803 : # define YY_REDUCE_PRINT(Rule) \
804 : do { \
805 : if (yydebug) \
806 : yy_reduce_print (yyssp, yyvsp, Rule, context); \
807 : } while (0)
808 :
809 : /* Nonzero means print parse trace. It is left uninitialized so that
810 : multiple parsers can coexist. */
811 : int yydebug;
812 : #else /* !YYDEBUG */
813 : # define YYDPRINTF(Args)
814 : # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
815 : # define YY_STACK_PRINT(Bottom, Top)
816 : # define YY_REDUCE_PRINT(Rule)
817 : #endif /* !YYDEBUG */
818 :
819 :
820 : /* YYINITDEPTH -- initial size of the parser's stacks. */
821 : #ifndef YYINITDEPTH
822 : # define YYINITDEPTH 200
823 : #endif
824 :
825 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
826 : if the built-in stack extension method is used).
827 :
828 : Do not make this value too large; the results are undefined if
829 : YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
830 : evaluated with infinite-precision integer arithmetic. */
831 :
832 : #ifndef YYMAXDEPTH
833 : # define YYMAXDEPTH 10000
834 : #endif
835 :
836 :
837 : #if YYERROR_VERBOSE
838 :
839 : # ifndef yystrlen
840 : # if defined __GLIBC__ && defined _STRING_H
841 : # define yystrlen strlen
842 : # else
843 : /* Return the length of YYSTR. */
844 : static YYSIZE_T
845 : yystrlen (const char *yystr)
846 : {
847 : YYSIZE_T yylen;
848 : for (yylen = 0; yystr[yylen]; yylen++)
849 : continue;
850 : return yylen;
851 : }
852 : # endif
853 : # endif
854 :
855 : # ifndef yystpcpy
856 : # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
857 : # define yystpcpy stpcpy
858 : # else
859 : /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
860 : YYDEST. */
861 : static char *
862 : yystpcpy (char *yydest, const char *yysrc)
863 : {
864 : char *yyd = yydest;
865 : const char *yys = yysrc;
866 :
867 : while ((*yyd++ = *yys++) != '\0')
868 : continue;
869 :
870 : return yyd - 1;
871 : }
872 : # endif
873 : # endif
874 :
875 : # ifndef yytnamerr
876 : /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
877 : quotes and backslashes, so that it's suitable for yyerror. The
878 : heuristic is that double-quoting is unnecessary unless the string
879 : contains an apostrophe, a comma, or backslash (other than
880 : backslash-backslash). YYSTR is taken from yytname. If YYRES is
881 : null, do not copy; instead, return the length of what the result
882 : would have been. */
883 : static YYSIZE_T
884 : yytnamerr (char *yyres, const char *yystr)
885 : {
886 : if (*yystr == '"')
887 : {
888 : YYSIZE_T yyn = 0;
889 : char const *yyp = yystr;
890 :
891 : for (;;)
892 : switch (*++yyp)
893 : {
894 : case '\'':
895 : case ',':
896 : goto do_not_strip_quotes;
897 :
898 : case '\\':
899 : if (*++yyp != '\\')
900 : goto do_not_strip_quotes;
901 : /* Fall through. */
902 : default:
903 : if (yyres)
904 : yyres[yyn] = *yyp;
905 : yyn++;
906 : break;
907 :
908 : case '"':
909 : if (yyres)
910 : yyres[yyn] = '\0';
911 : return yyn;
912 : }
913 : do_not_strip_quotes: ;
914 : }
915 :
916 : if (! yyres)
917 : return yystrlen (yystr);
918 :
919 : return yystpcpy (yyres, yystr) - yyres;
920 : }
921 : # endif
922 :
923 : /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
924 : about the unexpected token YYTOKEN for the state stack whose top is
925 : YYSSP.
926 :
927 : Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
928 : not large enough to hold the message. In that case, also set
929 : *YYMSG_ALLOC to the required number of bytes. Return 2 if the
930 : required number of bytes is too large to store. */
931 : static int
932 : yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
933 : yytype_int16 *yyssp, int yytoken)
934 : {
935 : YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
936 : YYSIZE_T yysize = yysize0;
937 : enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
938 : /* Internationalized format string. */
939 : const char *yyformat = YY_NULLPTR;
940 : /* Arguments of yyformat. */
941 : char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
942 : /* Number of reported tokens (one for the "unexpected", one per
943 : "expected"). */
944 : int yycount = 0;
945 :
946 : /* There are many possibilities here to consider:
947 : - If this state is a consistent state with a default action, then
948 : the only way this function was invoked is if the default action
949 : is an error action. In that case, don't check for expected
950 : tokens because there are none.
951 : - The only way there can be no lookahead present (in yychar) is if
952 : this state is a consistent state with a default action. Thus,
953 : detecting the absence of a lookahead is sufficient to determine
954 : that there is no unexpected or expected token to report. In that
955 : case, just report a simple "syntax error".
956 : - Don't assume there isn't a lookahead just because this state is a
957 : consistent state with a default action. There might have been a
958 : previous inconsistent state, consistent state with a non-default
959 : action, or user semantic action that manipulated yychar.
960 : - Of course, the expected token list depends on states to have
961 : correct lookahead information, and it depends on the parser not
962 : to perform extra reductions after fetching a lookahead from the
963 : scanner and before detecting a syntax error. Thus, state merging
964 : (from LALR or IELR) and default reductions corrupt the expected
965 : token list. However, the list is correct for canonical LR with
966 : one exception: it will still contain any token that will not be
967 : accepted due to an error action in a later state.
968 : */
969 : if (yytoken != YYEMPTY)
970 : {
971 : int yyn = yypact[*yyssp];
972 : yyarg[yycount++] = yytname[yytoken];
973 : if (!yypact_value_is_default (yyn))
974 : {
975 : /* Start YYX at -YYN if negative to avoid negative indexes in
976 : YYCHECK. In other words, skip the first -YYN actions for
977 : this state because they are default actions. */
978 : int yyxbegin = yyn < 0 ? -yyn : 0;
979 : /* Stay within bounds of both yycheck and yytname. */
980 : int yychecklim = YYLAST - yyn + 1;
981 : int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
982 : int yyx;
983 :
984 : for (yyx = yyxbegin; yyx < yyxend; ++yyx)
985 : if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
986 : && !yytable_value_is_error (yytable[yyx + yyn]))
987 : {
988 : if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
989 : {
990 : yycount = 1;
991 : yysize = yysize0;
992 : break;
993 : }
994 : yyarg[yycount++] = yytname[yyx];
995 : {
996 : YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
997 : if (! (yysize <= yysize1
998 : && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
999 : return 2;
1000 : yysize = yysize1;
1001 : }
1002 : }
1003 : }
1004 : }
1005 :
1006 : switch (yycount)
1007 : {
1008 : # define YYCASE_(N, S) \
1009 : case N: \
1010 : yyformat = S; \
1011 : break
1012 : YYCASE_(0, YY_("syntax error"));
1013 : YYCASE_(1, YY_("syntax error, unexpected %s"));
1014 : YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1015 : YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1016 : YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1017 : YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1018 : # undef YYCASE_
1019 : }
1020 :
1021 : {
1022 : YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1023 : if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1024 : return 2;
1025 : yysize = yysize1;
1026 : }
1027 :
1028 : if (*yymsg_alloc < yysize)
1029 : {
1030 : *yymsg_alloc = 2 * yysize;
1031 : if (! (yysize <= *yymsg_alloc
1032 : && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1033 : *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1034 : return 1;
1035 : }
1036 :
1037 : /* Avoid sprintf, as that infringes on the user's name space.
1038 : Don't have undefined behavior even if the translation
1039 : produced a string with the wrong number of "%s"s. */
1040 : {
1041 : char *yyp = *yymsg;
1042 : int yyi = 0;
1043 : while ((*yyp = *yyformat) != '\0')
1044 : if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1045 : {
1046 : yyp += yytnamerr (yyp, yyarg[yyi++]);
1047 : yyformat += 2;
1048 : }
1049 : else
1050 : {
1051 : yyp++;
1052 : yyformat++;
1053 : }
1054 : }
1055 : return 0;
1056 : }
1057 : #endif /* YYERROR_VERBOSE */
1058 :
1059 : /*-----------------------------------------------.
1060 : | Release the memory associated to this symbol. |
1061 : `-----------------------------------------------*/
1062 :
1063 : static void
1064 0 : yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context)
1065 : {
1066 : YYUSE (yyvaluep);
1067 : YYUSE (context);
1068 0 : if (!yymsg)
1069 0 : yymsg = "Deleting";
1070 : YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1071 :
1072 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1073 : YYUSE (yytype);
1074 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1075 0 : }
1076 :
1077 :
1078 :
1079 :
1080 : /*----------.
1081 : | yyparse. |
1082 : `----------*/
1083 :
1084 : int
1085 0 : yyparse (Context *context)
1086 : {
1087 : /* The lookahead symbol. */
1088 : int yychar;
1089 :
1090 :
1091 : /* The semantic value of the lookahead symbol. */
1092 : /* Default value used for initialization, for pacifying older GCCs
1093 : or non-GCC compilers. */
1094 : YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1095 : YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1096 :
1097 : /* Number of syntax errors so far. */
1098 : int yynerrs;
1099 :
1100 : int yystate;
1101 : /* Number of tokens to shift before error messages enabled. */
1102 : int yyerrstatus;
1103 :
1104 : /* The stacks and their tools:
1105 : 'yyss': related to states.
1106 : 'yyvs': related to semantic values.
1107 :
1108 : Refer to the stacks through separate pointers, to allow yyoverflow
1109 : to reallocate them elsewhere. */
1110 :
1111 : /* The state stack. */
1112 : yytype_int16 yyssa[YYINITDEPTH];
1113 : yytype_int16 *yyss;
1114 : yytype_int16 *yyssp;
1115 :
1116 : /* The semantic value stack. */
1117 : YYSTYPE yyvsa[YYINITDEPTH];
1118 : YYSTYPE *yyvs;
1119 : YYSTYPE *yyvsp;
1120 :
1121 : YYSIZE_T yystacksize;
1122 :
1123 : int yyn;
1124 : int yyresult;
1125 : /* Lookahead token as an internal (translated) token number. */
1126 0 : int yytoken = 0;
1127 : /* The variables used to return semantic value and location from the
1128 : action routines. */
1129 : YYSTYPE yyval;
1130 :
1131 : #if YYERROR_VERBOSE
1132 : /* Buffer for error messages, and its allocated size. */
1133 : char yymsgbuf[128];
1134 : char *yymsg = yymsgbuf;
1135 : YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1136 : #endif
1137 :
1138 : #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1139 :
1140 : /* The number of symbols on the RHS of the reduced rule.
1141 : Keep to zero when no symbol should be popped. */
1142 0 : int yylen = 0;
1143 :
1144 0 : yyssp = yyss = yyssa;
1145 0 : yyvsp = yyvs = yyvsa;
1146 0 : yystacksize = YYINITDEPTH;
1147 :
1148 : YYDPRINTF ((stderr, "Starting parse\n"));
1149 :
1150 0 : yystate = 0;
1151 0 : yyerrstatus = 0;
1152 0 : yynerrs = 0;
1153 0 : yychar = YYEMPTY; /* Cause a token to be read. */
1154 0 : goto yysetstate;
1155 :
1156 : /*------------------------------------------------------------.
1157 : | yynewstate -- Push a new state, which is found in yystate. |
1158 : `------------------------------------------------------------*/
1159 : yynewstate:
1160 : /* In all cases, when you get here, the value and location stacks
1161 : have just been pushed. So pushing a state here evens the stacks. */
1162 0 : yyssp++;
1163 :
1164 : yysetstate:
1165 0 : *yyssp = yystate;
1166 :
1167 0 : if (yyss + yystacksize - 1 <= yyssp)
1168 : {
1169 : /* Get the current used size of the three stacks, in elements. */
1170 0 : YYSIZE_T yysize = yyssp - yyss + 1;
1171 :
1172 : #ifdef yyoverflow
1173 : {
1174 : /* Give user a chance to reallocate the stack. Use copies of
1175 : these so that the &'s don't force the real ones into
1176 : memory. */
1177 : YYSTYPE *yyvs1 = yyvs;
1178 : yytype_int16 *yyss1 = yyss;
1179 :
1180 : /* Each stack pointer address is followed by the size of the
1181 : data in use in that stack, in bytes. This used to be a
1182 : conditional around just the two extra args, but that might
1183 : be undefined if yyoverflow is a macro. */
1184 : yyoverflow (YY_("memory exhausted"),
1185 : &yyss1, yysize * sizeof (*yyssp),
1186 : &yyvs1, yysize * sizeof (*yyvsp),
1187 : &yystacksize);
1188 :
1189 : yyss = yyss1;
1190 : yyvs = yyvs1;
1191 : }
1192 : #else /* no yyoverflow */
1193 : # ifndef YYSTACK_RELOCATE
1194 : goto yyexhaustedlab;
1195 : # else
1196 : /* Extend the stack our own way. */
1197 0 : if (YYMAXDEPTH <= yystacksize)
1198 0 : goto yyexhaustedlab;
1199 0 : yystacksize *= 2;
1200 0 : if (YYMAXDEPTH < yystacksize)
1201 0 : yystacksize = YYMAXDEPTH;
1202 :
1203 : {
1204 0 : yytype_int16 *yyss1 = yyss;
1205 : union yyalloc *yyptr =
1206 0 : (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1207 0 : if (! yyptr)
1208 0 : goto yyexhaustedlab;
1209 0 : YYSTACK_RELOCATE (yyss_alloc, yyss);
1210 0 : YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1211 : # undef YYSTACK_RELOCATE
1212 0 : if (yyss1 != yyssa)
1213 0 : YYSTACK_FREE (yyss1);
1214 : }
1215 : # endif
1216 : #endif /* no yyoverflow */
1217 :
1218 0 : yyssp = yyss + yysize - 1;
1219 0 : yyvsp = yyvs + yysize - 1;
1220 :
1221 : YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1222 : (unsigned long int) yystacksize));
1223 :
1224 0 : if (yyss + yystacksize - 1 <= yyssp)
1225 0 : YYABORT;
1226 : }
1227 :
1228 : YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1229 :
1230 0 : if (yystate == YYFINAL)
1231 0 : YYACCEPT;
1232 :
1233 0 : goto yybackup;
1234 :
1235 : /*-----------.
1236 : | yybackup. |
1237 : `-----------*/
1238 : yybackup:
1239 :
1240 : /* Do appropriate processing given the current state. Read a
1241 : lookahead token if we need one and don't already have one. */
1242 :
1243 : /* First try to decide what to do without reference to lookahead token. */
1244 0 : yyn = yypact[yystate];
1245 0 : if (yypact_value_is_default (yyn))
1246 0 : goto yydefault;
1247 :
1248 : /* Not known => get a lookahead token if don't already have one. */
1249 :
1250 : /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1251 0 : if (yychar == YYEMPTY)
1252 : {
1253 : YYDPRINTF ((stderr, "Reading a token: "));
1254 0 : yychar = yylex (&yylval, context);
1255 : }
1256 :
1257 0 : if (yychar <= YYEOF)
1258 : {
1259 0 : yychar = yytoken = YYEOF;
1260 : YYDPRINTF ((stderr, "Now at end of input.\n"));
1261 : }
1262 : else
1263 : {
1264 0 : yytoken = YYTRANSLATE (yychar);
1265 : YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1266 : }
1267 :
1268 : /* If the proper action on seeing token YYTOKEN is to reduce or to
1269 : detect an error, take that action. */
1270 0 : yyn += yytoken;
1271 0 : if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1272 : goto yydefault;
1273 0 : yyn = yytable[yyn];
1274 0 : if (yyn <= 0)
1275 : {
1276 : if (yytable_value_is_error (yyn))
1277 : goto yyerrlab;
1278 0 : yyn = -yyn;
1279 0 : goto yyreduce;
1280 : }
1281 :
1282 : /* Count tokens shifted since error; after three, turn off error
1283 : status. */
1284 0 : if (yyerrstatus)
1285 0 : yyerrstatus--;
1286 :
1287 : /* Shift the lookahead token. */
1288 : YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1289 :
1290 : /* Discard the shifted token. */
1291 0 : yychar = YYEMPTY;
1292 :
1293 0 : yystate = yyn;
1294 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1295 0 : *++yyvsp = yylval;
1296 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1297 :
1298 0 : goto yynewstate;
1299 :
1300 :
1301 : /*-----------------------------------------------------------.
1302 : | yydefault -- do the default action for the current state. |
1303 : `-----------------------------------------------------------*/
1304 : yydefault:
1305 0 : yyn = yydefact[yystate];
1306 0 : if (yyn == 0)
1307 0 : goto yyerrlab;
1308 0 : goto yyreduce;
1309 :
1310 :
1311 : /*-----------------------------.
1312 : | yyreduce -- Do a reduction. |
1313 : `-----------------------------*/
1314 : yyreduce:
1315 : /* yyn is the number of a rule to reduce with. */
1316 0 : yylen = yyr2[yyn];
1317 :
1318 : /* If YYLEN is nonzero, implement the default value of the action:
1319 : '$$ = $1'.
1320 :
1321 : Otherwise, the following line sets YYVAL to garbage.
1322 : This behavior is undocumented and Bison
1323 : users should not rely upon it. Assigning to YYVAL
1324 : unconditionally makes the parser a bit smaller, and it avoids a
1325 : GCC warning that YYVAL may be used uninitialized. */
1326 0 : yyval = yyvsp[1-yylen];
1327 :
1328 :
1329 : YY_REDUCE_PRINT (yyn);
1330 0 : switch (yyn)
1331 : {
1332 : case 2:
1333 :
1334 : {
1335 0 : *(context->result) = static_cast<int>((yyvsp[0]));
1336 0 : YYACCEPT;
1337 : }
1338 :
1339 : break;
1340 :
1341 : case 4:
1342 :
1343 : {
1344 0 : if (!context->isIgnoringErrors())
1345 : {
1346 : // This rule should be applied right after the token is lexed, so we can
1347 : // refer to context->token in the error message.
1348 0 : context->diagnostics->report(context->errorSettings.unexpectedIdentifier,
1349 0 : context->token->location, context->token->text);
1350 0 : *(context->valid) = false;
1351 : }
1352 0 : (yyval) = (yyvsp[0]);
1353 : }
1354 :
1355 0 : break;
1356 :
1357 : case 5:
1358 :
1359 : {
1360 0 : if ((yyvsp[-1]) != 0)
1361 : {
1362 : // Ignore errors in the short-circuited part of the expression.
1363 : // ESSL3.00 section 3.4:
1364 : // If an operand is not evaluated, the presence of undefined identifiers
1365 : // in the operand will not cause an error.
1366 : // Unevaluated division by zero should not cause an error either.
1367 0 : context->startIgnoreErrors();
1368 : }
1369 : }
1370 :
1371 0 : break;
1372 :
1373 : case 6:
1374 :
1375 : {
1376 0 : if ((yyvsp[-3]) != 0)
1377 : {
1378 0 : context->endIgnoreErrors();
1379 0 : (yyval) = static_cast<YYSTYPE>(1);
1380 : }
1381 : else
1382 : {
1383 0 : (yyval) = (yyvsp[-3]) || (yyvsp[0]);
1384 : }
1385 : }
1386 :
1387 0 : break;
1388 :
1389 : case 7:
1390 :
1391 : {
1392 0 : if ((yyvsp[-1]) == 0)
1393 : {
1394 : // Ignore errors in the short-circuited part of the expression.
1395 : // ESSL3.00 section 3.4:
1396 : // If an operand is not evaluated, the presence of undefined identifiers
1397 : // in the operand will not cause an error.
1398 : // Unevaluated division by zero should not cause an error either.
1399 0 : context->startIgnoreErrors();
1400 : }
1401 : }
1402 :
1403 0 : break;
1404 :
1405 : case 8:
1406 :
1407 : {
1408 0 : if ((yyvsp[-3]) == 0)
1409 : {
1410 0 : context->endIgnoreErrors();
1411 0 : (yyval) = static_cast<YYSTYPE>(0);
1412 : }
1413 : else
1414 : {
1415 0 : (yyval) = (yyvsp[-3]) && (yyvsp[0]);
1416 : }
1417 : }
1418 :
1419 0 : break;
1420 :
1421 : case 9:
1422 :
1423 : {
1424 0 : (yyval) = (yyvsp[-2]) | (yyvsp[0]);
1425 : }
1426 :
1427 0 : break;
1428 :
1429 : case 10:
1430 :
1431 : {
1432 0 : (yyval) = (yyvsp[-2]) ^ (yyvsp[0]);
1433 : }
1434 :
1435 0 : break;
1436 :
1437 : case 11:
1438 :
1439 : {
1440 0 : (yyval) = (yyvsp[-2]) & (yyvsp[0]);
1441 : }
1442 :
1443 0 : break;
1444 :
1445 : case 12:
1446 :
1447 : {
1448 0 : (yyval) = (yyvsp[-2]) != (yyvsp[0]);
1449 : }
1450 :
1451 0 : break;
1452 :
1453 : case 13:
1454 :
1455 : {
1456 0 : (yyval) = (yyvsp[-2]) == (yyvsp[0]);
1457 : }
1458 :
1459 0 : break;
1460 :
1461 : case 14:
1462 :
1463 : {
1464 0 : (yyval) = (yyvsp[-2]) >= (yyvsp[0]);
1465 : }
1466 :
1467 0 : break;
1468 :
1469 : case 15:
1470 :
1471 : {
1472 0 : (yyval) = (yyvsp[-2]) <= (yyvsp[0]);
1473 : }
1474 :
1475 0 : break;
1476 :
1477 : case 16:
1478 :
1479 : {
1480 0 : (yyval) = (yyvsp[-2]) > (yyvsp[0]);
1481 : }
1482 :
1483 0 : break;
1484 :
1485 : case 17:
1486 :
1487 : {
1488 0 : (yyval) = (yyvsp[-2]) < (yyvsp[0]);
1489 : }
1490 :
1491 0 : break;
1492 :
1493 : case 18:
1494 :
1495 : {
1496 0 : if ((yyvsp[0]) < 0 || (yyvsp[0]) > 31)
1497 : {
1498 0 : if (!context->isIgnoringErrors())
1499 : {
1500 0 : std::ostringstream stream;
1501 0 : stream << (yyvsp[-2]) << " >> " << (yyvsp[0]);
1502 0 : std::string text = stream.str();
1503 0 : context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
1504 0 : context->token->location,
1505 0 : text.c_str());
1506 0 : *(context->valid) = false;
1507 : }
1508 0 : (yyval) = static_cast<YYSTYPE>(0);
1509 : }
1510 0 : else if ((yyvsp[-2]) < 0)
1511 : {
1512 : // Logical shift right.
1513 0 : (yyval) = static_cast<YYSTYPE>(static_cast<UNSIGNED_TYPE>((yyvsp[-2])) >> (yyvsp[0]));
1514 : }
1515 : else
1516 : {
1517 0 : (yyval) = (yyvsp[-2]) >> (yyvsp[0]);
1518 : }
1519 : }
1520 :
1521 0 : break;
1522 :
1523 : case 19:
1524 :
1525 : {
1526 0 : if ((yyvsp[0]) < 0 || (yyvsp[0]) > 31)
1527 : {
1528 0 : if (!context->isIgnoringErrors())
1529 : {
1530 0 : std::ostringstream stream;
1531 0 : stream << (yyvsp[-2]) << " << " << (yyvsp[0]);
1532 0 : std::string text = stream.str();
1533 0 : context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
1534 0 : context->token->location,
1535 0 : text.c_str());
1536 0 : *(context->valid) = false;
1537 : }
1538 0 : (yyval) = static_cast<YYSTYPE>(0);
1539 : }
1540 0 : else if ((yyvsp[-2]) < 0)
1541 : {
1542 : // Logical shift left.
1543 0 : (yyval) = static_cast<YYSTYPE>(static_cast<UNSIGNED_TYPE>((yyvsp[-2])) << (yyvsp[0]));
1544 : }
1545 : else
1546 : {
1547 0 : (yyval) = (yyvsp[-2]) << (yyvsp[0]);
1548 : }
1549 : }
1550 :
1551 0 : break;
1552 :
1553 : case 20:
1554 :
1555 : {
1556 0 : (yyval) = gl::WrappingDiff<YYSTYPE>((yyvsp[-2]), (yyvsp[0]));
1557 : }
1558 :
1559 0 : break;
1560 :
1561 : case 21:
1562 :
1563 : {
1564 0 : (yyval) = gl::WrappingSum<YYSTYPE>((yyvsp[-2]), (yyvsp[0]));
1565 : }
1566 :
1567 0 : break;
1568 :
1569 : case 22:
1570 :
1571 : {
1572 0 : if ((yyvsp[0]) == 0)
1573 : {
1574 0 : if (!context->isIgnoringErrors())
1575 : {
1576 0 : std::ostringstream stream;
1577 0 : stream << (yyvsp[-2]) << " % " << (yyvsp[0]);
1578 0 : std::string text = stream.str();
1579 0 : context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
1580 0 : context->token->location,
1581 0 : text.c_str());
1582 0 : *(context->valid) = false;
1583 : }
1584 0 : (yyval) = static_cast<YYSTYPE>(0);
1585 : }
1586 0 : else if (((yyvsp[-2]) == std::numeric_limits<YYSTYPE>::min()) && ((yyvsp[0]) == -1))
1587 : {
1588 : // Check for the special case where the minimum representable number is
1589 : // divided by -1. If left alone this has undefined results.
1590 0 : (yyval) = 0;
1591 : }
1592 : else
1593 : {
1594 0 : (yyval) = (yyvsp[-2]) % (yyvsp[0]);
1595 : }
1596 : }
1597 :
1598 0 : break;
1599 :
1600 : case 23:
1601 :
1602 : {
1603 0 : if ((yyvsp[0]) == 0)
1604 : {
1605 0 : if (!context->isIgnoringErrors())
1606 : {
1607 0 : std::ostringstream stream;
1608 0 : stream << (yyvsp[-2]) << " / " << (yyvsp[0]);
1609 0 : std::string text = stream.str();
1610 0 : context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
1611 0 : context->token->location,
1612 0 : text.c_str());
1613 0 : *(context->valid) = false;
1614 : }
1615 0 : (yyval) = static_cast<YYSTYPE>(0);
1616 : }
1617 0 : else if (((yyvsp[-2]) == std::numeric_limits<YYSTYPE>::min()) && ((yyvsp[0]) == -1))
1618 : {
1619 : // Check for the special case where the minimum representable number is
1620 : // divided by -1. If left alone this leads to integer overflow in C++, which
1621 : // has undefined results.
1622 0 : (yyval) = std::numeric_limits<YYSTYPE>::max();
1623 : }
1624 : else
1625 : {
1626 0 : (yyval) = (yyvsp[-2]) / (yyvsp[0]);
1627 : }
1628 : }
1629 :
1630 0 : break;
1631 :
1632 : case 24:
1633 :
1634 : {
1635 0 : (yyval) = gl::WrappingMul((yyvsp[-2]), (yyvsp[0]));
1636 : }
1637 :
1638 0 : break;
1639 :
1640 : case 25:
1641 :
1642 : {
1643 0 : (yyval) = ! (yyvsp[0]);
1644 : }
1645 :
1646 0 : break;
1647 :
1648 : case 26:
1649 :
1650 : {
1651 0 : (yyval) = ~ (yyvsp[0]);
1652 : }
1653 :
1654 0 : break;
1655 :
1656 : case 27:
1657 :
1658 : {
1659 : // Check for negation of minimum representable integer to prevent undefined signed int
1660 : // overflow.
1661 0 : if ((yyvsp[0]) == std::numeric_limits<YYSTYPE>::min())
1662 : {
1663 0 : (yyval) = std::numeric_limits<YYSTYPE>::min();
1664 : }
1665 : else
1666 : {
1667 0 : (yyval) = -(yyvsp[0]);
1668 : }
1669 : }
1670 :
1671 0 : break;
1672 :
1673 : case 28:
1674 :
1675 : {
1676 0 : (yyval) = + (yyvsp[0]);
1677 : }
1678 :
1679 0 : break;
1680 :
1681 : case 29:
1682 :
1683 : {
1684 0 : (yyval) = (yyvsp[-1]);
1685 : }
1686 :
1687 0 : break;
1688 :
1689 :
1690 :
1691 0 : default: break;
1692 : }
1693 : /* User semantic actions sometimes alter yychar, and that requires
1694 : that yytoken be updated with the new translation. We take the
1695 : approach of translating immediately before every use of yytoken.
1696 : One alternative is translating here after every semantic action,
1697 : but that translation would be missed if the semantic action invokes
1698 : YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1699 : if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1700 : incorrect destructor might then be invoked immediately. In the
1701 : case of YYERROR or YYBACKUP, subsequent parser actions might lead
1702 : to an incorrect destructor call or verbose syntax error message
1703 : before the lookahead is translated. */
1704 : YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1705 :
1706 0 : YYPOPSTACK (yylen);
1707 0 : yylen = 0;
1708 : YY_STACK_PRINT (yyss, yyssp);
1709 :
1710 0 : *++yyvsp = yyval;
1711 :
1712 : /* Now 'shift' the result of the reduction. Determine what state
1713 : that goes to, based on the state we popped back to and the rule
1714 : number reduced by. */
1715 :
1716 0 : yyn = yyr1[yyn];
1717 :
1718 0 : yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1719 0 : if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1720 0 : yystate = yytable[yystate];
1721 : else
1722 0 : yystate = yydefgoto[yyn - YYNTOKENS];
1723 :
1724 0 : goto yynewstate;
1725 :
1726 :
1727 : /*--------------------------------------.
1728 : | yyerrlab -- here on detecting error. |
1729 : `--------------------------------------*/
1730 : yyerrlab:
1731 : /* Make sure we have latest lookahead translation. See comments at
1732 : user semantic actions for why this is necessary. */
1733 0 : yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1734 :
1735 : /* If not already recovering from an error, report this error. */
1736 0 : if (!yyerrstatus)
1737 : {
1738 0 : ++yynerrs;
1739 : #if ! YYERROR_VERBOSE
1740 0 : yyerror (context, YY_("syntax error"));
1741 : #else
1742 : # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1743 : yyssp, yytoken)
1744 : {
1745 : char const *yymsgp = YY_("syntax error");
1746 : int yysyntax_error_status;
1747 : yysyntax_error_status = YYSYNTAX_ERROR;
1748 : if (yysyntax_error_status == 0)
1749 : yymsgp = yymsg;
1750 : else if (yysyntax_error_status == 1)
1751 : {
1752 : if (yymsg != yymsgbuf)
1753 : YYSTACK_FREE (yymsg);
1754 : yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1755 : if (!yymsg)
1756 : {
1757 : yymsg = yymsgbuf;
1758 : yymsg_alloc = sizeof yymsgbuf;
1759 : yysyntax_error_status = 2;
1760 : }
1761 : else
1762 : {
1763 : yysyntax_error_status = YYSYNTAX_ERROR;
1764 : yymsgp = yymsg;
1765 : }
1766 : }
1767 : yyerror (context, yymsgp);
1768 : if (yysyntax_error_status == 2)
1769 : goto yyexhaustedlab;
1770 : }
1771 : # undef YYSYNTAX_ERROR
1772 : #endif
1773 : }
1774 :
1775 :
1776 :
1777 0 : if (yyerrstatus == 3)
1778 : {
1779 : /* If just tried and failed to reuse lookahead token after an
1780 : error, discard it. */
1781 :
1782 0 : if (yychar <= YYEOF)
1783 : {
1784 : /* Return failure if at end of input. */
1785 0 : if (yychar == YYEOF)
1786 0 : YYABORT;
1787 : }
1788 : else
1789 : {
1790 : yydestruct ("Error: discarding",
1791 0 : yytoken, &yylval, context);
1792 0 : yychar = YYEMPTY;
1793 : }
1794 : }
1795 :
1796 : /* Else will try to reuse lookahead token after shifting the error
1797 : token. */
1798 0 : goto yyerrlab1;
1799 :
1800 :
1801 : /*---------------------------------------------------.
1802 : | yyerrorlab -- error raised explicitly by YYERROR. |
1803 : `---------------------------------------------------*/
1804 : yyerrorlab:
1805 :
1806 : /* Pacify compilers like GCC when the user code never invokes
1807 : YYERROR and the label yyerrorlab therefore never appears in user
1808 : code. */
1809 : if (/*CONSTCOND*/ 0)
1810 : goto yyerrorlab;
1811 :
1812 : /* Do not reclaim the symbols of the rule whose action triggered
1813 : this YYERROR. */
1814 : YYPOPSTACK (yylen);
1815 : yylen = 0;
1816 : YY_STACK_PRINT (yyss, yyssp);
1817 : yystate = *yyssp;
1818 : goto yyerrlab1;
1819 :
1820 :
1821 : /*-------------------------------------------------------------.
1822 : | yyerrlab1 -- common code for both syntax error and YYERROR. |
1823 : `-------------------------------------------------------------*/
1824 : yyerrlab1:
1825 0 : yyerrstatus = 3; /* Each real token shifted decrements this. */
1826 :
1827 : for (;;)
1828 : {
1829 0 : yyn = yypact[yystate];
1830 0 : if (!yypact_value_is_default (yyn))
1831 : {
1832 0 : yyn += YYTERROR;
1833 0 : if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1834 : {
1835 0 : yyn = yytable[yyn];
1836 0 : if (0 < yyn)
1837 0 : break;
1838 : }
1839 : }
1840 :
1841 : /* Pop the current state because it cannot handle the error token. */
1842 0 : if (yyssp == yyss)
1843 0 : YYABORT;
1844 :
1845 :
1846 0 : yydestruct ("Error: popping",
1847 0 : yystos[yystate], yyvsp, context);
1848 0 : YYPOPSTACK (1);
1849 0 : yystate = *yyssp;
1850 : YY_STACK_PRINT (yyss, yyssp);
1851 : }
1852 :
1853 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1854 0 : *++yyvsp = yylval;
1855 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1856 :
1857 :
1858 : /* Shift the error token. */
1859 : YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1860 :
1861 0 : yystate = yyn;
1862 0 : goto yynewstate;
1863 :
1864 :
1865 : /*-------------------------------------.
1866 : | yyacceptlab -- YYACCEPT comes here. |
1867 : `-------------------------------------*/
1868 : yyacceptlab:
1869 0 : yyresult = 0;
1870 0 : goto yyreturn;
1871 :
1872 : /*-----------------------------------.
1873 : | yyabortlab -- YYABORT comes here. |
1874 : `-----------------------------------*/
1875 : yyabortlab:
1876 0 : yyresult = 1;
1877 0 : goto yyreturn;
1878 :
1879 : #if !defined yyoverflow || YYERROR_VERBOSE
1880 : /*-------------------------------------------------.
1881 : | yyexhaustedlab -- memory exhaustion comes here. |
1882 : `-------------------------------------------------*/
1883 : yyexhaustedlab:
1884 0 : yyerror (context, YY_("memory exhausted"));
1885 0 : yyresult = 2;
1886 : /* Fall through. */
1887 : #endif
1888 :
1889 : yyreturn:
1890 0 : if (yychar != YYEMPTY)
1891 : {
1892 : /* Make sure we have latest lookahead translation. See comments at
1893 : user semantic actions for why this is necessary. */
1894 0 : yytoken = YYTRANSLATE (yychar);
1895 : yydestruct ("Cleanup: discarding lookahead",
1896 0 : yytoken, &yylval, context);
1897 : }
1898 : /* Do not reclaim the symbols of the rule whose action triggered
1899 : this YYABORT or YYACCEPT. */
1900 0 : YYPOPSTACK (yylen);
1901 : YY_STACK_PRINT (yyss, yyssp);
1902 0 : while (yyssp != yyss)
1903 : {
1904 0 : yydestruct ("Cleanup: popping",
1905 0 : yystos[*yyssp], yyvsp, context);
1906 0 : YYPOPSTACK (1);
1907 : }
1908 : #ifndef yyoverflow
1909 0 : if (yyss != yyssa)
1910 0 : YYSTACK_FREE (yyss);
1911 : #endif
1912 : #if YYERROR_VERBOSE
1913 : if (yymsg != yymsgbuf)
1914 : YYSTACK_FREE (yymsg);
1915 : #endif
1916 0 : return yyresult;
1917 : }
1918 :
1919 :
1920 :
1921 0 : int yylex(YYSTYPE *lvalp, Context *context)
1922 : {
1923 0 : pp::Token *token = context->token;
1924 0 : if (!context->parsePresetToken)
1925 : {
1926 0 : context->lexer->lex(token);
1927 : }
1928 0 : context->parsePresetToken = false;
1929 :
1930 0 : int type = 0;
1931 :
1932 0 : switch (token->type)
1933 : {
1934 : case pp::Token::CONST_INT: {
1935 0 : unsigned int val = 0;
1936 0 : int testVal = 0;
1937 0 : if (!token->uValue(&val) || (!token->iValue(&testVal) &&
1938 0 : context->errorSettings.integerLiteralsMustFit32BitSignedRange))
1939 : {
1940 0 : context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
1941 0 : token->location, token->text);
1942 0 : *(context->valid) = false;
1943 : }
1944 0 : *lvalp = static_cast<YYSTYPE>(val);
1945 0 : type = TOK_CONST_INT;
1946 0 : break;
1947 : }
1948 : case pp::Token::IDENTIFIER:
1949 0 : *lvalp = static_cast<YYSTYPE>(-1);
1950 0 : type = TOK_IDENTIFIER;
1951 0 : break;
1952 : case pp::Token::OP_OR:
1953 0 : type = TOK_OP_OR;
1954 0 : break;
1955 : case pp::Token::OP_AND:
1956 0 : type = TOK_OP_AND;
1957 0 : break;
1958 : case pp::Token::OP_NE:
1959 0 : type = TOK_OP_NE;
1960 0 : break;
1961 : case pp::Token::OP_EQ:
1962 0 : type = TOK_OP_EQ;
1963 0 : break;
1964 : case pp::Token::OP_GE:
1965 0 : type = TOK_OP_GE;
1966 0 : break;
1967 : case pp::Token::OP_LE:
1968 0 : type = TOK_OP_LE;
1969 0 : break;
1970 : case pp::Token::OP_RIGHT:
1971 0 : type = TOK_OP_RIGHT;
1972 0 : break;
1973 : case pp::Token::OP_LEFT:
1974 0 : type = TOK_OP_LEFT;
1975 0 : break;
1976 : case '|':
1977 : case '^':
1978 : case '&':
1979 : case '>':
1980 : case '<':
1981 : case '-':
1982 : case '+':
1983 : case '%':
1984 : case '/':
1985 : case '*':
1986 : case '!':
1987 : case '~':
1988 : case '(':
1989 : case ')':
1990 0 : type = token->type;
1991 0 : break;
1992 :
1993 : default:
1994 0 : break;
1995 : }
1996 :
1997 0 : return type;
1998 : }
1999 :
2000 0 : void yyerror(Context *context, const char *reason)
2001 : {
2002 0 : context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
2003 0 : context->token->location,
2004 0 : reason);
2005 0 : }
2006 :
2007 : namespace pp {
2008 :
2009 0 : ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics)
2010 : : mLexer(lexer),
2011 0 : mDiagnostics(diagnostics)
2012 : {
2013 0 : }
2014 :
2015 0 : bool ExpressionParser::parse(Token *token,
2016 : int *result,
2017 : bool parsePresetToken,
2018 : const ErrorSettings &errorSettings,
2019 : bool *valid)
2020 : {
2021 : Context context;
2022 0 : context.diagnostics = mDiagnostics;
2023 0 : context.lexer = mLexer;
2024 0 : context.token = token;
2025 0 : context.result = result;
2026 0 : context.ignoreErrors = 0;
2027 0 : context.parsePresetToken = parsePresetToken;
2028 0 : context.errorSettings = errorSettings;
2029 0 : context.valid = valid;
2030 0 : int ret = yyparse(&context);
2031 0 : switch (ret)
2032 : {
2033 : case 0:
2034 : case 1:
2035 0 : break;
2036 :
2037 : case 2:
2038 0 : mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
2039 0 : break;
2040 :
2041 : default:
2042 0 : assert(false);
2043 : mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
2044 : break;
2045 : }
2046 :
2047 0 : return ret == 0;
2048 : }
2049 :
2050 : } // namespace pp
|