blob: ceb91ca13b798c27188519dc4daa987f05ae7d26 [file] [log] [blame]
Jamie Madill185de882014-12-22 15:17:52 -05001/* A Bison parser, made by GNU Bison 3.0.2. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00003/* Bison implementation for Yacc-like parsers in C
Jamie Madill185de882014-12-22 15:17:52 -05004
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6
alokp@chromium.org04d7d222012-05-16 19:24:07 +00007 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.
Jamie Madill185de882014-12-22 15:17:52 -050011
alokp@chromium.org04d7d222012-05-16 19:24:07 +000012 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.
Jamie Madill185de882014-12-22 15:17:52 -050016
alokp@chromium.org04d7d222012-05-16 19:24:07 +000017 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.
Jamie Madill185de882014-12-22 15:17:52 -050029
alokp@chromium.org04d7d222012-05-16 19:24:07 +000030 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. */
Jamie Madill185de882014-12-22 15:17:52 -050047#define YYBISON_VERSION "3.0.2"
alokp@chromium.org04d7d222012-05-16 19:24:07 +000048
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
alokp@chromium.org04d7d222012-05-16 19:24:07 +000061
62/* Substitute the variable and function names. */
63#define yyparse ppparse
64#define yylex pplex
65#define yyerror pperror
alokp@chromium.org04d7d222012-05-16 19:24:07 +000066#define yydebug ppdebug
67#define yynerrs ppnerrs
68
Jamie Madill185de882014-12-22 15:17:52 -050069
alokp@chromium.org04d7d222012-05-16 19:24:07 +000070/* 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__)
maxvujovic@gmail.comc6b3b3c2012-06-27 22:49:39 +000082// Triggered by the auto-generated pplval variable.
shannon.woods@transgaming.comeb68fd02013-02-28 23:20:01 +000083#if !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
daniel@transgaming.comb3077d02013-01-11 04:12:09 +000084#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
shannon.woods@transgaming.comeb68fd02013-02-28 23:20:01 +000085#else
86#pragma GCC diagnostic ignored "-Wuninitialized"
shannon.woods@transgaming.come36fddf2013-01-25 21:57:50 +000087#endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +000088#elif defined(_MSC_VER)
89#pragma warning(disable: 4065 4701)
90#endif
91
92#include "ExpressionParser.h"
93
Jamie Madilla738f082013-11-01 17:45:04 -040094#if defined(_MSC_VER)
Jamie Madilld7f21352013-10-30 17:53:15 -040095#include <malloc.h>
Jamie Madilla738f082013-11-01 17:45:04 -040096#else
97#include <stdlib.h>
98#endif
99
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000100#include <cassert>
101#include <sstream>
102
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000103#include "DiagnosticsBase.h"
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000104#include "Lexer.h"
105#include "Token.h"
106
alokp@chromium.orgd39ec4c2012-06-26 04:37:55 +0000107#if defined(_MSC_VER)
108typedef __int64 YYSTYPE;
alokp@chromium.orgd39ec4c2012-06-26 04:37:55 +0000109#else
110#include <stdint.h>
111typedef intmax_t YYSTYPE;
112#endif // _MSC_VER
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000113#define YYENABLE_NLS 0
114#define YYLTYPE_IS_TRIVIAL 1
alokp@chromium.orgd39ec4c2012-06-26 04:37:55 +0000115#define YYSTYPE_IS_TRIVIAL 1
116#define YYSTYPE_IS_DECLARED 1
117
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000118namespace {
119struct Context
120{
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000121 pp::Diagnostics* diagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000122 pp::Lexer* lexer;
123 pp::Token* token;
124 int* result;
125};
126} // namespace
127
128
alokp@chromium.orgd39ec4c2012-06-26 04:37:55 +0000129static int yylex(YYSTYPE* lvalp, Context* context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000130static void yyerror(Context* context, const char* reason);
131
132
133
Jamie Madill185de882014-12-22 15:17:52 -0500134# ifndef YY_NULLPTR
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000135# if defined __cplusplus && 201103L <= __cplusplus
Jamie Madill185de882014-12-22 15:17:52 -0500136# define YY_NULLPTR nullptr
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000137# else
Jamie Madill185de882014-12-22 15:17:52 -0500138# define YY_NULLPTR 0
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000139# endif
140# endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000141
142/* Enabling verbose error messages. */
143#ifdef YYERROR_VERBOSE
144# undef YYERROR_VERBOSE
145# define YYERROR_VERBOSE 1
146#else
147# define YYERROR_VERBOSE 0
148#endif
149
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000150
Jamie Madill185de882014-12-22 15:17:52 -0500151/* Debug traces. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000152#ifndef YYDEBUG
153# define YYDEBUG 0
154#endif
155#if YYDEBUG
156extern int ppdebug;
157#endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000158
Jamie Madill185de882014-12-22 15:17:52 -0500159/* Token type. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000160#ifndef YYTOKENTYPE
161# define YYTOKENTYPE
Jamie Madill185de882014-12-22 15:17:52 -0500162 enum yytokentype
163 {
164 TOK_CONST_INT = 258,
165 TOK_OP_OR = 259,
166 TOK_OP_AND = 260,
167 TOK_OP_EQ = 261,
168 TOK_OP_NE = 262,
169 TOK_OP_LE = 263,
170 TOK_OP_GE = 264,
171 TOK_OP_LEFT = 265,
172 TOK_OP_RIGHT = 266,
173 TOK_UNARY = 267
174 };
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000175#endif
176
Jamie Madill185de882014-12-22 15:17:52 -0500177/* Value type. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000178#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
179typedef int YYSTYPE;
180# define YYSTYPE_IS_TRIVIAL 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000181# define YYSTYPE_IS_DECLARED 1
182#endif
183
184
Jamie Madill185de882014-12-22 15:17:52 -0500185
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000186int ppparse (Context *context);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000187
188
189
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000190/* Copy the second part of user declarations. */
191
192
193
194#ifdef short
195# undef short
196#endif
197
198#ifdef YYTYPE_UINT8
199typedef YYTYPE_UINT8 yytype_uint8;
200#else
201typedef unsigned char yytype_uint8;
202#endif
203
204#ifdef YYTYPE_INT8
205typedef YYTYPE_INT8 yytype_int8;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000206#else
Jamie Madill185de882014-12-22 15:17:52 -0500207typedef signed char yytype_int8;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000208#endif
209
210#ifdef YYTYPE_UINT16
211typedef YYTYPE_UINT16 yytype_uint16;
212#else
213typedef unsigned short int yytype_uint16;
214#endif
215
216#ifdef YYTYPE_INT16
217typedef YYTYPE_INT16 yytype_int16;
218#else
219typedef short int yytype_int16;
220#endif
221
222#ifndef YYSIZE_T
223# ifdef __SIZE_TYPE__
224# define YYSIZE_T __SIZE_TYPE__
225# elif defined size_t
226# define YYSIZE_T size_t
Jamie Madill185de882014-12-22 15:17:52 -0500227# elif ! defined YYSIZE_T
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000228# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
229# define YYSIZE_T size_t
230# else
231# define YYSIZE_T unsigned int
232# endif
233#endif
234
235#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
236
237#ifndef YY_
238# if defined YYENABLE_NLS && YYENABLE_NLS
239# if ENABLE_NLS
240# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000241# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000242# endif
243# endif
244# ifndef YY_
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000245# define YY_(Msgid) Msgid
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000246# endif
247#endif
248
Jamie Madill185de882014-12-22 15:17:52 -0500249#ifndef YY_ATTRIBUTE
250# if (defined __GNUC__ \
251 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
252 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
253# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
254# else
255# define YY_ATTRIBUTE(Spec) /* empty */
256# endif
257#endif
258
259#ifndef YY_ATTRIBUTE_PURE
260# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
261#endif
262
263#ifndef YY_ATTRIBUTE_UNUSED
264# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
265#endif
266
267#if !defined _Noreturn \
268 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
269# if defined _MSC_VER && 1200 <= _MSC_VER
270# define _Noreturn __declspec (noreturn)
271# else
272# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400273# endif
274#endif
275
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000276/* Suppress unused-variable warnings by "using" E. */
277#if ! defined lint || defined __GNUC__
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000278# define YYUSE(E) ((void) (E))
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000279#else
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000280# define YYUSE(E) /* empty */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000281#endif
282
Jamie Madill185de882014-12-22 15:17:52 -0500283#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
284/* Suppress an incorrect diagnostic about yylval being uninitialized. */
285# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
286 _Pragma ("GCC diagnostic push") \
287 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
288 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
289# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
290 _Pragma ("GCC diagnostic pop")
291#else
292# define YY_INITIAL_VALUE(Value) Value
293#endif
294#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
295# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
296# define YY_IGNORE_MAYBE_UNINITIALIZED_END
297#endif
298#ifndef YY_INITIAL_VALUE
299# define YY_INITIAL_VALUE(Value) /* Nothing. */
300#endif
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400301
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000302
303#if ! defined yyoverflow || YYERROR_VERBOSE
304
305/* The parser invokes alloca or malloc; define the necessary symbols. */
306
307# ifdef YYSTACK_USE_ALLOCA
308# if YYSTACK_USE_ALLOCA
309# ifdef __GNUC__
310# define YYSTACK_ALLOC __builtin_alloca
311# elif defined __BUILTIN_VA_ARG_INCR
312# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
313# elif defined _AIX
314# define YYSTACK_ALLOC __alloca
315# elif defined _MSC_VER
316# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
317# define alloca _alloca
318# else
319# define YYSTACK_ALLOC alloca
Jamie Madill185de882014-12-22 15:17:52 -0500320# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000321# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000322 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
323# ifndef EXIT_SUCCESS
324# define EXIT_SUCCESS 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000325# endif
326# endif
327# endif
328# endif
329# endif
330
331# ifdef YYSTACK_ALLOC
Jamie Madill185de882014-12-22 15:17:52 -0500332 /* Pacify GCC's 'empty if-body' warning. */
333# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000334# ifndef YYSTACK_ALLOC_MAXIMUM
335 /* The OS might guarantee only one guard page at the bottom of the stack,
336 and a page size can be as small as 4096 bytes. So we cannot safely
337 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
338 to allow for a few compiler-allocated temporary stack slots. */
339# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
340# endif
341# else
342# define YYSTACK_ALLOC YYMALLOC
343# define YYSTACK_FREE YYFREE
344# ifndef YYSTACK_ALLOC_MAXIMUM
345# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
346# endif
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000347# if (defined __cplusplus && ! defined EXIT_SUCCESS \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000348 && ! ((defined YYMALLOC || defined malloc) \
Jamie Madill185de882014-12-22 15:17:52 -0500349 && (defined YYFREE || defined free)))
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000350# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000351# ifndef EXIT_SUCCESS
352# define EXIT_SUCCESS 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000353# endif
354# endif
355# ifndef YYMALLOC
356# define YYMALLOC malloc
Jamie Madill185de882014-12-22 15:17:52 -0500357# if ! defined malloc && ! defined EXIT_SUCCESS
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000358void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
359# endif
360# endif
361# ifndef YYFREE
362# define YYFREE free
Jamie Madill185de882014-12-22 15:17:52 -0500363# if ! defined free && ! defined EXIT_SUCCESS
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000364void free (void *); /* INFRINGES ON USER NAME SPACE */
365# endif
366# endif
367# endif
368#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
369
370
371#if (! defined yyoverflow \
372 && (! defined __cplusplus \
Jamie Madill185de882014-12-22 15:17:52 -0500373 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000374
375/* A type that is properly aligned for any stack member. */
376union yyalloc
377{
378 yytype_int16 yyss_alloc;
379 YYSTYPE yyvs_alloc;
380};
381
382/* The size of the maximum gap between one aligned stack and the next. */
383# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
384
385/* The size of an array large to enough to hold all stacks, each with
386 N elements. */
387# define YYSTACK_BYTES(N) \
388 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
389 + YYSTACK_GAP_MAXIMUM)
390
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000391# define YYCOPY_NEEDED 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000392
393/* Relocate STACK from its old location to the new one. The
394 local variables YYSIZE and YYSTACKSIZE give the old and new number of
395 elements in the stack, and YYPTR gives the new location of the
396 stack. Advance YYPTR to a properly aligned location for the next
397 stack. */
Jamie Madill185de882014-12-22 15:17:52 -0500398# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
399 do \
400 { \
401 YYSIZE_T yynewbytes; \
402 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
403 Stack = &yyptr->Stack_alloc; \
404 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
405 yyptr += yynewbytes / sizeof (*yyptr); \
406 } \
407 while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000408
409#endif
410
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000411#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
412/* Copy COUNT objects from SRC to DST. The source and destination do
413 not overlap. */
414# ifndef YYCOPY
415# if defined __GNUC__ && 1 < __GNUC__
416# define YYCOPY(Dst, Src, Count) \
417 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
418# else
419# define YYCOPY(Dst, Src, Count) \
420 do \
421 { \
422 YYSIZE_T yyi; \
423 for (yyi = 0; yyi < (Count); yyi++) \
424 (Dst)[yyi] = (Src)[yyi]; \
425 } \
Jamie Madill185de882014-12-22 15:17:52 -0500426 while (0)
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000427# endif
428# endif
429#endif /* !YYCOPY_NEEDED */
430
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000431/* YYFINAL -- State number of the termination state. */
432#define YYFINAL 14
433/* YYLAST -- Last index in YYTABLE. */
434#define YYLAST 175
435
436/* YYNTOKENS -- Number of terminals. */
437#define YYNTOKENS 27
438/* YYNNTS -- Number of nonterminals. */
439#define YYNNTS 3
440/* YYNRULES -- Number of rules. */
441#define YYNRULES 26
Jamie Madill185de882014-12-22 15:17:52 -0500442/* YYNSTATES -- Number of states. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000443#define YYNSTATES 52
444
Jamie Madill185de882014-12-22 15:17:52 -0500445/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
446 by yylex, with out-of-bounds checking. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000447#define YYUNDEFTOK 2
448#define YYMAXUTOK 267
449
Jamie Madill185de882014-12-22 15:17:52 -0500450#define YYTRANSLATE(YYX) \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000451 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
452
Jamie Madill185de882014-12-22 15:17:52 -0500453/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
454 as returned by yylex, without out-of-bounds checking. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000455static const yytype_uint8 yytranslate[] =
456{
457 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460 2, 2, 2, 23, 2, 2, 2, 21, 8, 2,
461 25, 26, 19, 17, 2, 18, 2, 20, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 11, 2, 12, 2, 2, 2, 2, 2, 2, 2,
464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 7, 2, 2, 2, 2, 2,
467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 6, 2, 24, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 2, 2, 2, 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, 2, 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, 2, 2, 2, 2, 2, 2,
481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
483 5, 9, 10, 13, 14, 15, 16, 22
484};
485
486#if YYDEBUG
Jamie Madill185de882014-12-22 15:17:52 -0500487 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000488static const yytype_uint8 yyrline[] =
489{
Jamie Madillc9f140d2014-02-18 15:27:21 -0500490 0, 97, 97, 104, 105, 108, 111, 114, 117, 120,
491 123, 126, 129, 132, 135, 138, 141, 144, 147, 150,
492 163, 176, 179, 182, 185, 188, 191
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000493};
494#endif
495
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000496#if YYDEBUG || YYERROR_VERBOSE || 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000497/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
498 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
499static const char *const yytname[] =
500{
maxvujovic@gmail.come640ef82012-07-13 18:42:40 +0000501 "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_OP_OR",
Jamie Madill185de882014-12-22 15:17:52 -0500502 "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_EQ", "TOK_OP_NE", "'<'",
503 "'>'", "TOK_OP_LE", "TOK_OP_GE", "TOK_OP_LEFT", "TOK_OP_RIGHT", "'+'",
maxvujovic@gmail.come640ef82012-07-13 18:42:40 +0000504 "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('", "')'",
Jamie Madill185de882014-12-22 15:17:52 -0500505 "$accept", "input", "expression", YY_NULLPTR
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000506};
507#endif
508
509# ifdef YYPRINT
Jamie Madill185de882014-12-22 15:17:52 -0500510/* YYTOKNUM[NUM] -- (External) token number corresponding to the
511 (internal) symbol number NUM (which must be that of a token). */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000512static const yytype_uint16 yytoknum[] =
513{
514 0, 256, 257, 258, 259, 260, 124, 94, 38, 261,
515 262, 60, 62, 263, 264, 265, 266, 43, 45, 42,
516 47, 37, 267, 33, 126, 40, 41
517};
518# endif
519
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000520#define YYPACT_NINF -11
Jamie Madill185de882014-12-22 15:17:52 -0500521
522#define yypact_value_is_default(Yystate) \
523 (!!((Yystate) == (-11)))
524
525#define YYTABLE_NINF -1
526
527#define yytable_value_is_error(Yytable_value) \
528 0
529
530 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
531 STATE-NUM. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000532static const yytype_int16 yypact[] =
533{
534 46, -11, 46, 46, 46, 46, 46, 12, 68, -11,
535 -11, -11, -11, 27, -11, 46, 46, 46, 46, 46,
536 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
537 46, 46, 46, -11, 85, 101, 116, 130, 143, 154,
538 154, -10, -10, -10, -10, 37, 37, 31, 31, -11,
539 -11, -11
540};
541
Jamie Madill185de882014-12-22 15:17:52 -0500542 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
543 Performed when YYTABLE does not specify something else to do. Zero
544 means the default is an error. */
545static const yytype_uint8 yydefact[] =
546{
547 0, 3, 0, 0, 0, 0, 0, 0, 2, 25,
548 24, 22, 23, 0, 1, 0, 0, 0, 0, 0,
549 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
550 0, 0, 0, 26, 4, 5, 6, 7, 8, 10,
551 9, 14, 13, 12, 11, 16, 15, 18, 17, 21,
552 20, 19
553};
554
555 /* YYPGOTO[NTERM-NUM]. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000556static const yytype_int8 yypgoto[] =
557{
558 -11, -11, -2
559};
560
Jamie Madill185de882014-12-22 15:17:52 -0500561 /* YYDEFGOTO[NTERM-NUM]. */
562static const yytype_int8 yydefgoto[] =
563{
564 -1, 7, 8
565};
566
567 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
568 positive, shift that token. If negative, reduce the rule whose
569 number is the opposite. If YYTABLE_NINF, syntax error. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000570static const yytype_uint8 yytable[] =
571{
572 9, 10, 11, 12, 13, 26, 27, 28, 29, 30,
573 31, 32, 14, 34, 35, 36, 37, 38, 39, 40,
574 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
575 51, 15, 16, 17, 18, 19, 20, 21, 22, 23,
576 24, 25, 26, 27, 28, 29, 30, 31, 32, 1,
577 30, 31, 32, 33, 28, 29, 30, 31, 32, 0,
578 0, 0, 0, 2, 3, 0, 0, 0, 0, 4,
579 5, 6, 15, 16, 17, 18, 19, 20, 21, 22,
580 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
581 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
582 26, 27, 28, 29, 30, 31, 32, 17, 18, 19,
583 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
584 30, 31, 32, 18, 19, 20, 21, 22, 23, 24,
585 25, 26, 27, 28, 29, 30, 31, 32, 19, 20,
586 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
587 31, 32, 20, 21, 22, 23, 24, 25, 26, 27,
588 28, 29, 30, 31, 32, 22, 23, 24, 25, 26,
589 27, 28, 29, 30, 31, 32
590};
591
592static const yytype_int8 yycheck[] =
593{
594 2, 3, 4, 5, 6, 15, 16, 17, 18, 19,
595 20, 21, 0, 15, 16, 17, 18, 19, 20, 21,
596 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
597 32, 4, 5, 6, 7, 8, 9, 10, 11, 12,
598 13, 14, 15, 16, 17, 18, 19, 20, 21, 3,
599 19, 20, 21, 26, 17, 18, 19, 20, 21, -1,
600 -1, -1, -1, 17, 18, -1, -1, -1, -1, 23,
601 24, 25, 4, 5, 6, 7, 8, 9, 10, 11,
602 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
603 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
604 15, 16, 17, 18, 19, 20, 21, 6, 7, 8,
605 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
606 19, 20, 21, 7, 8, 9, 10, 11, 12, 13,
607 14, 15, 16, 17, 18, 19, 20, 21, 8, 9,
608 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
609 20, 21, 9, 10, 11, 12, 13, 14, 15, 16,
610 17, 18, 19, 20, 21, 11, 12, 13, 14, 15,
611 16, 17, 18, 19, 20, 21
612};
613
Jamie Madill185de882014-12-22 15:17:52 -0500614 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
615 symbol of state STATE-NUM. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000616static const yytype_uint8 yystos[] =
617{
618 0, 3, 17, 18, 23, 24, 25, 28, 29, 29,
619 29, 29, 29, 29, 0, 4, 5, 6, 7, 8,
620 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
621 19, 20, 21, 26, 29, 29, 29, 29, 29, 29,
622 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
623 29, 29
624};
625
Jamie Madill185de882014-12-22 15:17:52 -0500626 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
627static const yytype_uint8 yyr1[] =
628{
629 0, 27, 28, 29, 29, 29, 29, 29, 29, 29,
630 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
631 29, 29, 29, 29, 29, 29, 29
632};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000633
Jamie Madill185de882014-12-22 15:17:52 -0500634 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
635static const yytype_uint8 yyr2[] =
636{
637 0, 2, 1, 1, 3, 3, 3, 3, 3, 3,
638 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
639 3, 3, 2, 2, 2, 2, 3
640};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000641
642
Jamie Madill185de882014-12-22 15:17:52 -0500643#define yyerrok (yyerrstatus = 0)
644#define yyclearin (yychar = YYEMPTY)
645#define YYEMPTY (-2)
646#define YYEOF 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000647
Jamie Madill185de882014-12-22 15:17:52 -0500648#define YYACCEPT goto yyacceptlab
649#define YYABORT goto yyabortlab
650#define YYERROR goto yyerrorlab
651
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000652
653#define YYRECOVERING() (!!yyerrstatus)
654
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000655#define YYBACKUP(Token, Value) \
656do \
657 if (yychar == YYEMPTY) \
658 { \
659 yychar = (Token); \
660 yylval = (Value); \
661 YYPOPSTACK (yylen); \
662 yystate = *yyssp; \
663 goto yybackup; \
664 } \
665 else \
666 { \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000667 yyerror (context, YY_("syntax error: cannot back up")); \
Jamie Madill185de882014-12-22 15:17:52 -0500668 YYERROR; \
669 } \
670while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000671
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000672/* Error token number */
Jamie Madill185de882014-12-22 15:17:52 -0500673#define YYTERROR 1
674#define YYERRCODE 256
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000675
676
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000677
678/* Enable debugging if requested. */
679#if YYDEBUG
680
681# ifndef YYFPRINTF
682# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
683# define YYFPRINTF fprintf
684# endif
685
Jamie Madill185de882014-12-22 15:17:52 -0500686# define YYDPRINTF(Args) \
687do { \
688 if (yydebug) \
689 YYFPRINTF Args; \
690} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000691
Jamie Madill185de882014-12-22 15:17:52 -0500692/* This macro is provided for backward compatibility. */
693#ifndef YY_LOCATION_PRINT
694# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
695#endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000696
697
Jamie Madill185de882014-12-22 15:17:52 -0500698# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
699do { \
700 if (yydebug) \
701 { \
702 YYFPRINTF (stderr, "%s ", Title); \
703 yy_symbol_print (stderr, \
704 Type, Value, context); \
705 YYFPRINTF (stderr, "\n"); \
706 } \
707} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000708
Jamie Madill185de882014-12-22 15:17:52 -0500709
710/*----------------------------------------.
711| Print this symbol's value on YYOUTPUT. |
712`----------------------------------------*/
713
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000714static void
715yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000716{
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000717 FILE *yyo = yyoutput;
718 YYUSE (yyo);
Jamie Madill185de882014-12-22 15:17:52 -0500719 YYUSE (context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000720 if (!yyvaluep)
721 return;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000722# ifdef YYPRINT
723 if (yytype < YYNTOKENS)
724 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000725# endif
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400726 YYUSE (yytype);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000727}
728
729
730/*--------------------------------.
731| Print this symbol on YYOUTPUT. |
732`--------------------------------*/
733
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000734static void
735yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000736{
Jamie Madill185de882014-12-22 15:17:52 -0500737 YYFPRINTF (yyoutput, "%s %s (",
738 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000739
740 yy_symbol_value_print (yyoutput, yytype, yyvaluep, context);
741 YYFPRINTF (yyoutput, ")");
742}
743
744/*------------------------------------------------------------------.
745| yy_stack_print -- Print the state stack from its BOTTOM up to its |
746| TOP (included). |
747`------------------------------------------------------------------*/
748
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000749static void
750yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000751{
752 YYFPRINTF (stderr, "Stack now");
753 for (; yybottom <= yytop; yybottom++)
754 {
755 int yybot = *yybottom;
756 YYFPRINTF (stderr, " %d", yybot);
757 }
758 YYFPRINTF (stderr, "\n");
759}
760
Jamie Madill185de882014-12-22 15:17:52 -0500761# define YY_STACK_PRINT(Bottom, Top) \
762do { \
763 if (yydebug) \
764 yy_stack_print ((Bottom), (Top)); \
765} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000766
767
768/*------------------------------------------------.
769| Report that the YYRULE is going to be reduced. |
770`------------------------------------------------*/
771
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000772static void
Jamie Madill185de882014-12-22 15:17:52 -0500773yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000774{
Jamie Madill185de882014-12-22 15:17:52 -0500775 unsigned long int yylno = yyrline[yyrule];
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000776 int yynrhs = yyr2[yyrule];
777 int yyi;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000778 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
Jamie Madill185de882014-12-22 15:17:52 -0500779 yyrule - 1, yylno);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000780 /* The symbols being reduced. */
781 for (yyi = 0; yyi < yynrhs; yyi++)
782 {
783 YYFPRINTF (stderr, " $%d = ", yyi + 1);
Jamie Madill185de882014-12-22 15:17:52 -0500784 yy_symbol_print (stderr,
785 yystos[yyssp[yyi + 1 - yynrhs]],
786 &(yyvsp[(yyi + 1) - (yynrhs)])
787 , context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000788 YYFPRINTF (stderr, "\n");
789 }
790}
791
Jamie Madill185de882014-12-22 15:17:52 -0500792# define YY_REDUCE_PRINT(Rule) \
793do { \
794 if (yydebug) \
795 yy_reduce_print (yyssp, yyvsp, Rule, context); \
796} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000797
798/* Nonzero means print parse trace. It is left uninitialized so that
799 multiple parsers can coexist. */
800int yydebug;
801#else /* !YYDEBUG */
802# define YYDPRINTF(Args)
803# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
804# define YY_STACK_PRINT(Bottom, Top)
805# define YY_REDUCE_PRINT(Rule)
806#endif /* !YYDEBUG */
807
808
809/* YYINITDEPTH -- initial size of the parser's stacks. */
Jamie Madill185de882014-12-22 15:17:52 -0500810#ifndef YYINITDEPTH
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000811# define YYINITDEPTH 200
812#endif
813
814/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
815 if the built-in stack extension method is used).
816
817 Do not make this value too large; the results are undefined if
818 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
819 evaluated with infinite-precision integer arithmetic. */
820
821#ifndef YYMAXDEPTH
822# define YYMAXDEPTH 10000
823#endif
824
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000825
826#if YYERROR_VERBOSE
827
828# ifndef yystrlen
829# if defined __GLIBC__ && defined _STRING_H
830# define yystrlen strlen
831# else
832/* Return the length of YYSTR. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000833static YYSIZE_T
834yystrlen (const char *yystr)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000835{
836 YYSIZE_T yylen;
837 for (yylen = 0; yystr[yylen]; yylen++)
838 continue;
839 return yylen;
840}
841# endif
842# endif
843
844# ifndef yystpcpy
845# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
846# define yystpcpy stpcpy
847# else
848/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
849 YYDEST. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000850static char *
851yystpcpy (char *yydest, const char *yysrc)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000852{
853 char *yyd = yydest;
854 const char *yys = yysrc;
855
856 while ((*yyd++ = *yys++) != '\0')
857 continue;
858
859 return yyd - 1;
860}
861# endif
862# endif
863
864# ifndef yytnamerr
865/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
866 quotes and backslashes, so that it's suitable for yyerror. The
867 heuristic is that double-quoting is unnecessary unless the string
868 contains an apostrophe, a comma, or backslash (other than
869 backslash-backslash). YYSTR is taken from yytname. If YYRES is
870 null, do not copy; instead, return the length of what the result
871 would have been. */
872static YYSIZE_T
873yytnamerr (char *yyres, const char *yystr)
874{
875 if (*yystr == '"')
876 {
877 YYSIZE_T yyn = 0;
878 char const *yyp = yystr;
879
880 for (;;)
Jamie Madill185de882014-12-22 15:17:52 -0500881 switch (*++yyp)
882 {
883 case '\'':
884 case ',':
885 goto do_not_strip_quotes;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000886
Jamie Madill185de882014-12-22 15:17:52 -0500887 case '\\':
888 if (*++yyp != '\\')
889 goto do_not_strip_quotes;
890 /* Fall through. */
891 default:
892 if (yyres)
893 yyres[yyn] = *yyp;
894 yyn++;
895 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000896
Jamie Madill185de882014-12-22 15:17:52 -0500897 case '"':
898 if (yyres)
899 yyres[yyn] = '\0';
900 return yyn;
901 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000902 do_not_strip_quotes: ;
903 }
904
905 if (! yyres)
906 return yystrlen (yystr);
907
908 return yystpcpy (yyres, yystr) - yyres;
909}
910# endif
911
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000912/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
913 about the unexpected token YYTOKEN for the state stack whose top is
914 YYSSP.
915
916 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
917 not large enough to hold the message. In that case, also set
918 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
919 required number of bytes is too large to store. */
920static int
921yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
922 yytype_int16 *yyssp, int yytoken)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000923{
Jamie Madill185de882014-12-22 15:17:52 -0500924 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000925 YYSIZE_T yysize = yysize0;
926 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
927 /* Internationalized format string. */
Jamie Madill185de882014-12-22 15:17:52 -0500928 const char *yyformat = YY_NULLPTR;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000929 /* Arguments of yyformat. */
930 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
931 /* Number of reported tokens (one for the "unexpected", one per
932 "expected"). */
933 int yycount = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000934
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000935 /* There are many possibilities here to consider:
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000936 - If this state is a consistent state with a default action, then
937 the only way this function was invoked is if the default action
938 is an error action. In that case, don't check for expected
939 tokens because there are none.
940 - The only way there can be no lookahead present (in yychar) is if
941 this state is a consistent state with a default action. Thus,
942 detecting the absence of a lookahead is sufficient to determine
943 that there is no unexpected or expected token to report. In that
944 case, just report a simple "syntax error".
945 - Don't assume there isn't a lookahead just because this state is a
946 consistent state with a default action. There might have been a
947 previous inconsistent state, consistent state with a non-default
948 action, or user semantic action that manipulated yychar.
949 - Of course, the expected token list depends on states to have
950 correct lookahead information, and it depends on the parser not
951 to perform extra reductions after fetching a lookahead from the
952 scanner and before detecting a syntax error. Thus, state merging
953 (from LALR or IELR) and default reductions corrupt the expected
954 token list. However, the list is correct for canonical LR with
955 one exception: it will still contain any token that will not be
956 accepted due to an error action in a later state.
957 */
958 if (yytoken != YYEMPTY)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000959 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000960 int yyn = yypact[*yyssp];
961 yyarg[yycount++] = yytname[yytoken];
962 if (!yypact_value_is_default (yyn))
963 {
964 /* Start YYX at -YYN if negative to avoid negative indexes in
965 YYCHECK. In other words, skip the first -YYN actions for
966 this state because they are default actions. */
967 int yyxbegin = yyn < 0 ? -yyn : 0;
968 /* Stay within bounds of both yycheck and yytname. */
969 int yychecklim = YYLAST - yyn + 1;
970 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
971 int yyx;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000972
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000973 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
974 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
975 && !yytable_value_is_error (yytable[yyx + yyn]))
976 {
977 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
978 {
979 yycount = 1;
980 yysize = yysize0;
981 break;
982 }
983 yyarg[yycount++] = yytname[yyx];
984 {
Jamie Madill185de882014-12-22 15:17:52 -0500985 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000986 if (! (yysize <= yysize1
987 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
988 return 2;
989 yysize = yysize1;
990 }
991 }
992 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000993 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000994
995 switch (yycount)
996 {
997# define YYCASE_(N, S) \
998 case N: \
999 yyformat = S; \
1000 break
1001 YYCASE_(0, YY_("syntax error"));
1002 YYCASE_(1, YY_("syntax error, unexpected %s"));
1003 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1004 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1005 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1006 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1007# undef YYCASE_
1008 }
1009
1010 {
1011 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1012 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1013 return 2;
1014 yysize = yysize1;
1015 }
1016
1017 if (*yymsg_alloc < yysize)
1018 {
1019 *yymsg_alloc = 2 * yysize;
1020 if (! (yysize <= *yymsg_alloc
1021 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1022 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1023 return 1;
1024 }
1025
1026 /* Avoid sprintf, as that infringes on the user's name space.
1027 Don't have undefined behavior even if the translation
1028 produced a string with the wrong number of "%s"s. */
1029 {
1030 char *yyp = *yymsg;
1031 int yyi = 0;
1032 while ((*yyp = *yyformat) != '\0')
1033 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1034 {
1035 yyp += yytnamerr (yyp, yyarg[yyi++]);
1036 yyformat += 2;
1037 }
1038 else
1039 {
1040 yyp++;
1041 yyformat++;
1042 }
1043 }
1044 return 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001045}
1046#endif /* YYERROR_VERBOSE */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001047
1048/*-----------------------------------------------.
1049| Release the memory associated to this symbol. |
1050`-----------------------------------------------*/
1051
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001052static void
1053yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001054{
1055 YYUSE (yyvaluep);
1056 YYUSE (context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001057 if (!yymsg)
1058 yymsg = "Deleting";
1059 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1060
Jamie Madill185de882014-12-22 15:17:52 -05001061 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001062 YYUSE (yytype);
Jamie Madill185de882014-12-22 15:17:52 -05001063 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001064}
1065
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001066
1067
1068
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001069/*----------.
1070| yyparse. |
1071`----------*/
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001072
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001073int
1074yyparse (Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001075{
1076/* The lookahead symbol. */
1077int yychar;
1078
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001079
Jamie Madill185de882014-12-22 15:17:52 -05001080/* The semantic value of the lookahead symbol. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001081/* Default value used for initialization, for pacifying older GCCs
1082 or non-GCC compilers. */
Jamie Madill185de882014-12-22 15:17:52 -05001083YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1084YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001085
1086 /* Number of syntax errors so far. */
1087 int yynerrs;
1088
1089 int yystate;
1090 /* Number of tokens to shift before error messages enabled. */
1091 int yyerrstatus;
1092
1093 /* The stacks and their tools:
Jamie Madill185de882014-12-22 15:17:52 -05001094 'yyss': related to states.
1095 'yyvs': related to semantic values.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001096
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001097 Refer to the stacks through separate pointers, to allow yyoverflow
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001098 to reallocate them elsewhere. */
1099
1100 /* The state stack. */
1101 yytype_int16 yyssa[YYINITDEPTH];
1102 yytype_int16 *yyss;
1103 yytype_int16 *yyssp;
1104
1105 /* The semantic value stack. */
1106 YYSTYPE yyvsa[YYINITDEPTH];
1107 YYSTYPE *yyvs;
1108 YYSTYPE *yyvsp;
1109
1110 YYSIZE_T yystacksize;
1111
1112 int yyn;
1113 int yyresult;
1114 /* Lookahead token as an internal (translated) token number. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001115 int yytoken = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001116 /* The variables used to return semantic value and location from the
1117 action routines. */
1118 YYSTYPE yyval;
1119
1120#if YYERROR_VERBOSE
1121 /* Buffer for error messages, and its allocated size. */
1122 char yymsgbuf[128];
1123 char *yymsg = yymsgbuf;
1124 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1125#endif
1126
1127#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1128
1129 /* The number of symbols on the RHS of the reduced rule.
1130 Keep to zero when no symbol should be popped. */
1131 int yylen = 0;
1132
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001133 yyssp = yyss = yyssa;
1134 yyvsp = yyvs = yyvsa;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001135 yystacksize = YYINITDEPTH;
1136
1137 YYDPRINTF ((stderr, "Starting parse\n"));
1138
1139 yystate = 0;
1140 yyerrstatus = 0;
1141 yynerrs = 0;
1142 yychar = YYEMPTY; /* Cause a token to be read. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001143 goto yysetstate;
1144
1145/*------------------------------------------------------------.
1146| yynewstate -- Push a new state, which is found in yystate. |
1147`------------------------------------------------------------*/
1148 yynewstate:
1149 /* In all cases, when you get here, the value and location stacks
1150 have just been pushed. So pushing a state here evens the stacks. */
1151 yyssp++;
1152
1153 yysetstate:
1154 *yyssp = yystate;
1155
1156 if (yyss + yystacksize - 1 <= yyssp)
1157 {
1158 /* Get the current used size of the three stacks, in elements. */
1159 YYSIZE_T yysize = yyssp - yyss + 1;
1160
1161#ifdef yyoverflow
1162 {
Jamie Madill185de882014-12-22 15:17:52 -05001163 /* Give user a chance to reallocate the stack. Use copies of
1164 these so that the &'s don't force the real ones into
1165 memory. */
1166 YYSTYPE *yyvs1 = yyvs;
1167 yytype_int16 *yyss1 = yyss;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001168
Jamie Madill185de882014-12-22 15:17:52 -05001169 /* Each stack pointer address is followed by the size of the
1170 data in use in that stack, in bytes. This used to be a
1171 conditional around just the two extra args, but that might
1172 be undefined if yyoverflow is a macro. */
1173 yyoverflow (YY_("memory exhausted"),
1174 &yyss1, yysize * sizeof (*yyssp),
1175 &yyvs1, yysize * sizeof (*yyvsp),
1176 &yystacksize);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001177
Jamie Madill185de882014-12-22 15:17:52 -05001178 yyss = yyss1;
1179 yyvs = yyvs1;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001180 }
1181#else /* no yyoverflow */
1182# ifndef YYSTACK_RELOCATE
1183 goto yyexhaustedlab;
1184# else
1185 /* Extend the stack our own way. */
1186 if (YYMAXDEPTH <= yystacksize)
Jamie Madill185de882014-12-22 15:17:52 -05001187 goto yyexhaustedlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001188 yystacksize *= 2;
1189 if (YYMAXDEPTH < yystacksize)
Jamie Madill185de882014-12-22 15:17:52 -05001190 yystacksize = YYMAXDEPTH;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001191
1192 {
Jamie Madill185de882014-12-22 15:17:52 -05001193 yytype_int16 *yyss1 = yyss;
1194 union yyalloc *yyptr =
1195 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1196 if (! yyptr)
1197 goto yyexhaustedlab;
1198 YYSTACK_RELOCATE (yyss_alloc, yyss);
1199 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001200# undef YYSTACK_RELOCATE
Jamie Madill185de882014-12-22 15:17:52 -05001201 if (yyss1 != yyssa)
1202 YYSTACK_FREE (yyss1);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001203 }
1204# endif
1205#endif /* no yyoverflow */
1206
1207 yyssp = yyss + yysize - 1;
1208 yyvsp = yyvs + yysize - 1;
1209
1210 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
Jamie Madill185de882014-12-22 15:17:52 -05001211 (unsigned long int) yystacksize));
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001212
1213 if (yyss + yystacksize - 1 <= yyssp)
Jamie Madill185de882014-12-22 15:17:52 -05001214 YYABORT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001215 }
1216
1217 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1218
1219 if (yystate == YYFINAL)
1220 YYACCEPT;
1221
1222 goto yybackup;
1223
1224/*-----------.
1225| yybackup. |
1226`-----------*/
1227yybackup:
1228
1229 /* Do appropriate processing given the current state. Read a
1230 lookahead token if we need one and don't already have one. */
1231
1232 /* First try to decide what to do without reference to lookahead token. */
1233 yyn = yypact[yystate];
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001234 if (yypact_value_is_default (yyn))
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001235 goto yydefault;
1236
1237 /* Not known => get a lookahead token if don't already have one. */
1238
1239 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1240 if (yychar == YYEMPTY)
1241 {
1242 YYDPRINTF ((stderr, "Reading a token: "));
Jamie Madill185de882014-12-22 15:17:52 -05001243 yychar = yylex (&yylval, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001244 }
1245
1246 if (yychar <= YYEOF)
1247 {
1248 yychar = yytoken = YYEOF;
1249 YYDPRINTF ((stderr, "Now at end of input.\n"));
1250 }
1251 else
1252 {
1253 yytoken = YYTRANSLATE (yychar);
1254 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1255 }
1256
1257 /* If the proper action on seeing token YYTOKEN is to reduce or to
1258 detect an error, take that action. */
1259 yyn += yytoken;
1260 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1261 goto yydefault;
1262 yyn = yytable[yyn];
1263 if (yyn <= 0)
1264 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001265 if (yytable_value_is_error (yyn))
1266 goto yyerrlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001267 yyn = -yyn;
1268 goto yyreduce;
1269 }
1270
1271 /* Count tokens shifted since error; after three, turn off error
1272 status. */
1273 if (yyerrstatus)
1274 yyerrstatus--;
1275
1276 /* Shift the lookahead token. */
1277 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1278
1279 /* Discard the shifted token. */
1280 yychar = YYEMPTY;
1281
1282 yystate = yyn;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001283 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001284 *++yyvsp = yylval;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001285 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001286
1287 goto yynewstate;
1288
1289
1290/*-----------------------------------------------------------.
1291| yydefault -- do the default action for the current state. |
1292`-----------------------------------------------------------*/
1293yydefault:
1294 yyn = yydefact[yystate];
1295 if (yyn == 0)
1296 goto yyerrlab;
1297 goto yyreduce;
1298
1299
1300/*-----------------------------.
1301| yyreduce -- Do a reduction. |
1302`-----------------------------*/
1303yyreduce:
1304 /* yyn is the number of a rule to reduce with. */
1305 yylen = yyr2[yyn];
1306
1307 /* If YYLEN is nonzero, implement the default value of the action:
Jamie Madill185de882014-12-22 15:17:52 -05001308 '$$ = $1'.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001309
1310 Otherwise, the following line sets YYVAL to garbage.
1311 This behavior is undocumented and Bison
1312 users should not rely upon it. Assigning to YYVAL
1313 unconditionally makes the parser a bit smaller, and it avoids a
1314 GCC warning that YYVAL may be used uninitialized. */
1315 yyval = yyvsp[1-yylen];
1316
1317
1318 YY_REDUCE_PRINT (yyn);
1319 switch (yyn)
1320 {
1321 case 2:
1322
1323 {
Jamie Madill185de882014-12-22 15:17:52 -05001324 *(context->result) = static_cast<int>((yyvsp[0]));
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001325 YYACCEPT;
1326 }
Jamie Madill185de882014-12-22 15:17:52 -05001327
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001328 break;
1329
1330 case 4:
1331
1332 {
Jamie Madill185de882014-12-22 15:17:52 -05001333 (yyval) = (yyvsp[-2]) || (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001334 }
Jamie Madill185de882014-12-22 15:17:52 -05001335
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001336 break;
1337
1338 case 5:
1339
1340 {
Jamie Madill185de882014-12-22 15:17:52 -05001341 (yyval) = (yyvsp[-2]) && (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001342 }
Jamie Madill185de882014-12-22 15:17:52 -05001343
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001344 break;
1345
1346 case 6:
1347
1348 {
Jamie Madill185de882014-12-22 15:17:52 -05001349 (yyval) = (yyvsp[-2]) | (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001350 }
Jamie Madill185de882014-12-22 15:17:52 -05001351
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001352 break;
1353
1354 case 7:
1355
1356 {
Jamie Madill185de882014-12-22 15:17:52 -05001357 (yyval) = (yyvsp[-2]) ^ (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001358 }
Jamie Madill185de882014-12-22 15:17:52 -05001359
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001360 break;
1361
1362 case 8:
1363
1364 {
Jamie Madill185de882014-12-22 15:17:52 -05001365 (yyval) = (yyvsp[-2]) & (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001366 }
Jamie Madill185de882014-12-22 15:17:52 -05001367
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001368 break;
1369
1370 case 9:
1371
1372 {
Jamie Madill185de882014-12-22 15:17:52 -05001373 (yyval) = (yyvsp[-2]) != (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001374 }
Jamie Madill185de882014-12-22 15:17:52 -05001375
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001376 break;
1377
1378 case 10:
1379
1380 {
Jamie Madill185de882014-12-22 15:17:52 -05001381 (yyval) = (yyvsp[-2]) == (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001382 }
Jamie Madill185de882014-12-22 15:17:52 -05001383
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001384 break;
1385
1386 case 11:
1387
1388 {
Jamie Madill185de882014-12-22 15:17:52 -05001389 (yyval) = (yyvsp[-2]) >= (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001390 }
Jamie Madill185de882014-12-22 15:17:52 -05001391
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001392 break;
1393
1394 case 12:
1395
1396 {
Jamie Madill185de882014-12-22 15:17:52 -05001397 (yyval) = (yyvsp[-2]) <= (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001398 }
Jamie Madill185de882014-12-22 15:17:52 -05001399
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001400 break;
1401
1402 case 13:
1403
1404 {
Jamie Madill185de882014-12-22 15:17:52 -05001405 (yyval) = (yyvsp[-2]) > (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001406 }
Jamie Madill185de882014-12-22 15:17:52 -05001407
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001408 break;
1409
1410 case 14:
1411
1412 {
Jamie Madill185de882014-12-22 15:17:52 -05001413 (yyval) = (yyvsp[-2]) < (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001414 }
Jamie Madill185de882014-12-22 15:17:52 -05001415
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001416 break;
1417
1418 case 15:
1419
1420 {
Jamie Madill185de882014-12-22 15:17:52 -05001421 (yyval) = (yyvsp[-2]) >> (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001422 }
Jamie Madill185de882014-12-22 15:17:52 -05001423
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001424 break;
1425
1426 case 16:
1427
1428 {
Jamie Madill185de882014-12-22 15:17:52 -05001429 (yyval) = (yyvsp[-2]) << (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001430 }
Jamie Madill185de882014-12-22 15:17:52 -05001431
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001432 break;
1433
1434 case 17:
1435
1436 {
Jamie Madill185de882014-12-22 15:17:52 -05001437 (yyval) = (yyvsp[-2]) - (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001438 }
Jamie Madill185de882014-12-22 15:17:52 -05001439
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001440 break;
1441
1442 case 18:
1443
1444 {
Jamie Madill185de882014-12-22 15:17:52 -05001445 (yyval) = (yyvsp[-2]) + (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001446 }
Jamie Madill185de882014-12-22 15:17:52 -05001447
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001448 break;
1449
1450 case 19:
1451
1452 {
Jamie Madill185de882014-12-22 15:17:52 -05001453 if ((yyvsp[0]) == 0) {
alokp@chromium.org2e818912012-06-29 21:26:03 +00001454 std::ostringstream stream;
Jamie Madill185de882014-12-22 15:17:52 -05001455 stream << (yyvsp[-2]) << " % " << (yyvsp[0]);
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001456 std::string text = stream.str();
Shannon Woods7f2d7942013-11-19 15:07:58 -05001457 context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001458 context->token->location,
1459 text.c_str());
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001460 YYABORT;
1461 } else {
Jamie Madill185de882014-12-22 15:17:52 -05001462 (yyval) = (yyvsp[-2]) % (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001463 }
1464 }
Jamie Madill185de882014-12-22 15:17:52 -05001465
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001466 break;
1467
1468 case 20:
1469
1470 {
Jamie Madill185de882014-12-22 15:17:52 -05001471 if ((yyvsp[0]) == 0) {
alokp@chromium.org2e818912012-06-29 21:26:03 +00001472 std::ostringstream stream;
Jamie Madill185de882014-12-22 15:17:52 -05001473 stream << (yyvsp[-2]) << " / " << (yyvsp[0]);
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001474 std::string text = stream.str();
Shannon Woods7f2d7942013-11-19 15:07:58 -05001475 context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001476 context->token->location,
1477 text.c_str());
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001478 YYABORT;
1479 } else {
Jamie Madill185de882014-12-22 15:17:52 -05001480 (yyval) = (yyvsp[-2]) / (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001481 }
1482 }
Jamie Madill185de882014-12-22 15:17:52 -05001483
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001484 break;
1485
1486 case 21:
1487
1488 {
Jamie Madill185de882014-12-22 15:17:52 -05001489 (yyval) = (yyvsp[-2]) * (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001490 }
Jamie Madill185de882014-12-22 15:17:52 -05001491
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001492 break;
1493
1494 case 22:
1495
1496 {
Jamie Madill185de882014-12-22 15:17:52 -05001497 (yyval) = ! (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001498 }
Jamie Madill185de882014-12-22 15:17:52 -05001499
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001500 break;
1501
1502 case 23:
1503
1504 {
Jamie Madill185de882014-12-22 15:17:52 -05001505 (yyval) = ~ (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001506 }
Jamie Madill185de882014-12-22 15:17:52 -05001507
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001508 break;
1509
1510 case 24:
1511
1512 {
Jamie Madill185de882014-12-22 15:17:52 -05001513 (yyval) = - (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001514 }
Jamie Madill185de882014-12-22 15:17:52 -05001515
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001516 break;
1517
1518 case 25:
1519
1520 {
Jamie Madill185de882014-12-22 15:17:52 -05001521 (yyval) = + (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001522 }
Jamie Madill185de882014-12-22 15:17:52 -05001523
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001524 break;
1525
1526 case 26:
1527
1528 {
Jamie Madill185de882014-12-22 15:17:52 -05001529 (yyval) = (yyvsp[-1]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001530 }
Jamie Madill185de882014-12-22 15:17:52 -05001531
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001532 break;
1533
1534
1535
1536 default: break;
1537 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001538 /* User semantic actions sometimes alter yychar, and that requires
1539 that yytoken be updated with the new translation. We take the
1540 approach of translating immediately before every use of yytoken.
1541 One alternative is translating here after every semantic action,
1542 but that translation would be missed if the semantic action invokes
1543 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1544 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1545 incorrect destructor might then be invoked immediately. In the
1546 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1547 to an incorrect destructor call or verbose syntax error message
1548 before the lookahead is translated. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001549 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1550
1551 YYPOPSTACK (yylen);
1552 yylen = 0;
1553 YY_STACK_PRINT (yyss, yyssp);
1554
1555 *++yyvsp = yyval;
1556
Jamie Madill185de882014-12-22 15:17:52 -05001557 /* Now 'shift' the result of the reduction. Determine what state
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001558 that goes to, based on the state we popped back to and the rule
1559 number reduced by. */
1560
1561 yyn = yyr1[yyn];
1562
1563 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1564 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1565 yystate = yytable[yystate];
1566 else
1567 yystate = yydefgoto[yyn - YYNTOKENS];
1568
1569 goto yynewstate;
1570
1571
Jamie Madill185de882014-12-22 15:17:52 -05001572/*--------------------------------------.
1573| yyerrlab -- here on detecting error. |
1574`--------------------------------------*/
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001575yyerrlab:
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001576 /* Make sure we have latest lookahead translation. See comments at
1577 user semantic actions for why this is necessary. */
1578 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1579
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001580 /* If not already recovering from an error, report this error. */
1581 if (!yyerrstatus)
1582 {
1583 ++yynerrs;
1584#if ! YYERROR_VERBOSE
1585 yyerror (context, YY_("syntax error"));
1586#else
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001587# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1588 yyssp, yytoken)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001589 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001590 char const *yymsgp = YY_("syntax error");
1591 int yysyntax_error_status;
1592 yysyntax_error_status = YYSYNTAX_ERROR;
1593 if (yysyntax_error_status == 0)
1594 yymsgp = yymsg;
1595 else if (yysyntax_error_status == 1)
1596 {
1597 if (yymsg != yymsgbuf)
1598 YYSTACK_FREE (yymsg);
1599 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1600 if (!yymsg)
1601 {
1602 yymsg = yymsgbuf;
1603 yymsg_alloc = sizeof yymsgbuf;
1604 yysyntax_error_status = 2;
1605 }
1606 else
1607 {
1608 yysyntax_error_status = YYSYNTAX_ERROR;
1609 yymsgp = yymsg;
1610 }
1611 }
1612 yyerror (context, yymsgp);
1613 if (yysyntax_error_status == 2)
1614 goto yyexhaustedlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001615 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001616# undef YYSYNTAX_ERROR
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001617#endif
1618 }
1619
1620
1621
1622 if (yyerrstatus == 3)
1623 {
1624 /* If just tried and failed to reuse lookahead token after an
Jamie Madill185de882014-12-22 15:17:52 -05001625 error, discard it. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001626
1627 if (yychar <= YYEOF)
Jamie Madill185de882014-12-22 15:17:52 -05001628 {
1629 /* Return failure if at end of input. */
1630 if (yychar == YYEOF)
1631 YYABORT;
1632 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001633 else
Jamie Madill185de882014-12-22 15:17:52 -05001634 {
1635 yydestruct ("Error: discarding",
1636 yytoken, &yylval, context);
1637 yychar = YYEMPTY;
1638 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001639 }
1640
1641 /* Else will try to reuse lookahead token after shifting the error
1642 token. */
1643 goto yyerrlab1;
1644
1645
1646/*---------------------------------------------------.
1647| yyerrorlab -- error raised explicitly by YYERROR. |
1648`---------------------------------------------------*/
1649yyerrorlab:
1650
1651 /* Pacify compilers like GCC when the user code never invokes
1652 YYERROR and the label yyerrorlab therefore never appears in user
1653 code. */
1654 if (/*CONSTCOND*/ 0)
1655 goto yyerrorlab;
1656
Jamie Madill185de882014-12-22 15:17:52 -05001657 /* Do not reclaim the symbols of the rule whose action triggered
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001658 this YYERROR. */
1659 YYPOPSTACK (yylen);
1660 yylen = 0;
1661 YY_STACK_PRINT (yyss, yyssp);
1662 yystate = *yyssp;
1663 goto yyerrlab1;
1664
1665
1666/*-------------------------------------------------------------.
1667| yyerrlab1 -- common code for both syntax error and YYERROR. |
1668`-------------------------------------------------------------*/
1669yyerrlab1:
Jamie Madill185de882014-12-22 15:17:52 -05001670 yyerrstatus = 3; /* Each real token shifted decrements this. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001671
1672 for (;;)
1673 {
1674 yyn = yypact[yystate];
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001675 if (!yypact_value_is_default (yyn))
Jamie Madill185de882014-12-22 15:17:52 -05001676 {
1677 yyn += YYTERROR;
1678 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1679 {
1680 yyn = yytable[yyn];
1681 if (0 < yyn)
1682 break;
1683 }
1684 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001685
1686 /* Pop the current state because it cannot handle the error token. */
1687 if (yyssp == yyss)
Jamie Madill185de882014-12-22 15:17:52 -05001688 YYABORT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001689
1690
1691 yydestruct ("Error: popping",
Jamie Madill185de882014-12-22 15:17:52 -05001692 yystos[yystate], yyvsp, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001693 YYPOPSTACK (1);
1694 yystate = *yyssp;
1695 YY_STACK_PRINT (yyss, yyssp);
1696 }
1697
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001698 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001699 *++yyvsp = yylval;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001700 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001701
1702
1703 /* Shift the error token. */
1704 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1705
1706 yystate = yyn;
1707 goto yynewstate;
1708
1709
1710/*-------------------------------------.
1711| yyacceptlab -- YYACCEPT comes here. |
1712`-------------------------------------*/
1713yyacceptlab:
1714 yyresult = 0;
1715 goto yyreturn;
1716
1717/*-----------------------------------.
1718| yyabortlab -- YYABORT comes here. |
1719`-----------------------------------*/
1720yyabortlab:
1721 yyresult = 1;
1722 goto yyreturn;
1723
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001724#if !defined yyoverflow || YYERROR_VERBOSE
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001725/*-------------------------------------------------.
1726| yyexhaustedlab -- memory exhaustion comes here. |
1727`-------------------------------------------------*/
1728yyexhaustedlab:
1729 yyerror (context, YY_("memory exhausted"));
1730 yyresult = 2;
1731 /* Fall through. */
1732#endif
1733
1734yyreturn:
1735 if (yychar != YYEMPTY)
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001736 {
1737 /* Make sure we have latest lookahead translation. See comments at
1738 user semantic actions for why this is necessary. */
1739 yytoken = YYTRANSLATE (yychar);
1740 yydestruct ("Cleanup: discarding lookahead",
1741 yytoken, &yylval, context);
1742 }
Jamie Madill185de882014-12-22 15:17:52 -05001743 /* Do not reclaim the symbols of the rule whose action triggered
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001744 this YYABORT or YYACCEPT. */
1745 YYPOPSTACK (yylen);
1746 YY_STACK_PRINT (yyss, yyssp);
1747 while (yyssp != yyss)
1748 {
1749 yydestruct ("Cleanup: popping",
Jamie Madill185de882014-12-22 15:17:52 -05001750 yystos[*yyssp], yyvsp, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001751 YYPOPSTACK (1);
1752 }
1753#ifndef yyoverflow
1754 if (yyss != yyssa)
1755 YYSTACK_FREE (yyss);
1756#endif
1757#if YYERROR_VERBOSE
1758 if (yymsg != yymsgbuf)
1759 YYSTACK_FREE (yymsg);
1760#endif
Jamie Madill185de882014-12-22 15:17:52 -05001761 return yyresult;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001762}
1763
1764
1765
Zhenyao Mod526f982014-05-13 14:51:19 -07001766int yylex(YYSTYPE *lvalp, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001767{
1768 int type = 0;
1769
Zhenyao Mod526f982014-05-13 14:51:19 -07001770 pp::Token *token = context->token;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001771 switch (token->type)
1772 {
Zhenyao Mod526f982014-05-13 14:51:19 -07001773 case pp::Token::CONST_INT: {
alokp@chromium.org2e818912012-06-29 21:26:03 +00001774 unsigned int val = 0;
1775 if (!token->uValue(&val))
1776 {
Shannon Woods7f2d7942013-11-19 15:07:58 -05001777 context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
alokp@chromium.org2e818912012-06-29 21:26:03 +00001778 token->location, token->text);
1779 }
1780 *lvalp = static_cast<YYSTYPE>(val);
maxvujovic@gmail.come640ef82012-07-13 18:42:40 +00001781 type = TOK_CONST_INT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001782 break;
alokp@chromium.org2e818912012-06-29 21:26:03 +00001783 }
Zhenyao Mod526f982014-05-13 14:51:19 -07001784 case pp::Token::OP_OR:
1785 type = TOK_OP_OR;
1786 break;
1787 case pp::Token::OP_AND:
1788 type = TOK_OP_AND;
1789 break;
1790 case pp::Token::OP_NE:
1791 type = TOK_OP_NE;
1792 break;
1793 case pp::Token::OP_EQ:
1794 type = TOK_OP_EQ;
1795 break;
1796 case pp::Token::OP_GE:
1797 type = TOK_OP_GE;
1798 break;
1799 case pp::Token::OP_LE:
1800 type = TOK_OP_LE;
1801 break;
1802 case pp::Token::OP_RIGHT:
1803 type = TOK_OP_RIGHT;
1804 break;
1805 case pp::Token::OP_LEFT:
1806 type = TOK_OP_LEFT;
1807 break;
1808 case '|':
1809 case '^':
1810 case '&':
1811 case '>':
1812 case '<':
1813 case '-':
1814 case '+':
1815 case '%':
1816 case '/':
1817 case '*':
1818 case '!':
1819 case '~':
1820 case '(':
1821 case ')':
1822 type = token->type;
1823 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001824
Zhenyao Mod526f982014-05-13 14:51:19 -07001825 default:
1826 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001827 }
1828
1829 // Advance to the next token if the current one is valid.
Zhenyao Mod526f982014-05-13 14:51:19 -07001830 if (type != 0)
1831 context->lexer->lex(token);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001832
1833 return type;
1834}
1835
Zhenyao Mod526f982014-05-13 14:51:19 -07001836void yyerror(Context *context, const char *reason)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001837{
Shannon Woods7f2d7942013-11-19 15:07:58 -05001838 context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001839 context->token->location,
1840 reason);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001841}
1842
1843namespace pp {
1844
Zhenyao Mod526f982014-05-13 14:51:19 -07001845ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics)
1846 : mLexer(lexer),
1847 mDiagnostics(diagnostics)
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001848{
1849}
1850
Zhenyao Mod526f982014-05-13 14:51:19 -07001851bool ExpressionParser::parse(Token *token, int *result)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001852{
1853 Context context;
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001854 context.diagnostics = mDiagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001855 context.lexer = mLexer;
1856 context.token = token;
1857 context.result = result;
1858 int ret = yyparse(&context);
1859 switch (ret)
1860 {
1861 case 0:
1862 case 1:
1863 break;
1864
1865 case 2:
Shannon Woods7f2d7942013-11-19 15:07:58 -05001866 mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001867 break;
1868
1869 default:
1870 assert(false);
Shannon Woods7f2d7942013-11-19 15:07:58 -05001871 mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001872 break;
1873 }
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001874
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001875 return ret == 0;
1876}
1877
1878} // namespace pp