blob: ddf810cb5c29b529903966464f38913105c063a5 [file] [log] [blame]
Jamie Madillb96687d2015-04-30 15:56:51 -04001/* A Bison parser, made by GNU Bison 3.0.4. */
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
Jamie Madillb96687d2015-04-30 15:56:51 -04005 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
Jamie Madill185de882014-12-22 15:17:52 -05006
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 Madillb96687d2015-04-30 15:56:51 -040047#define YYBISON_VERSION "3.0.4"
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)
Minmin Gong794e0002015-04-07 18:31:54 -070089#pragma warning(disable: 4065 4244 4701 4702)
alokp@chromium.org04d7d222012-05-16 19:24:07 +000090#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
Olli Etuaho3187a382015-09-09 12:00:12 +0300113
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000114#define YYENABLE_NLS 0
115#define YYLTYPE_IS_TRIVIAL 1
alokp@chromium.orgd39ec4c2012-06-26 04:37:55 +0000116#define YYSTYPE_IS_TRIVIAL 1
117#define YYSTYPE_IS_DECLARED 1
118
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000119namespace {
120struct Context
121{
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000122 pp::Diagnostics* diagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000123 pp::Lexer* lexer;
124 pp::Token* token;
125 int* result;
Olli Etuaho247374c2015-09-09 15:07:24 +0300126 bool parsePresetToken;
127
128 pp::ExpressionParser::ErrorSettings errorSettings;
129 bool *valid;
Olli Etuaho809ec542015-08-26 14:30:57 +0300130
131 void startIgnoreErrors() { ++ignoreErrors; }
132 void endIgnoreErrors() { --ignoreErrors; }
133
134 bool isIgnoringErrors() { return ignoreErrors > 0; }
135
136 int ignoreErrors;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000137};
138} // namespace
139
140
alokp@chromium.orgd39ec4c2012-06-26 04:37:55 +0000141static int yylex(YYSTYPE* lvalp, Context* context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000142static void yyerror(Context* context, const char* reason);
143
144
145
Jamie Madill185de882014-12-22 15:17:52 -0500146# ifndef YY_NULLPTR
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000147# if defined __cplusplus && 201103L <= __cplusplus
Jamie Madill185de882014-12-22 15:17:52 -0500148# define YY_NULLPTR nullptr
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000149# else
Jamie Madill185de882014-12-22 15:17:52 -0500150# define YY_NULLPTR 0
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000151# endif
152# endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000153
154/* Enabling verbose error messages. */
155#ifdef YYERROR_VERBOSE
156# undef YYERROR_VERBOSE
157# define YYERROR_VERBOSE 1
158#else
159# define YYERROR_VERBOSE 0
160#endif
161
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000162
Jamie Madill185de882014-12-22 15:17:52 -0500163/* Debug traces. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000164#ifndef YYDEBUG
165# define YYDEBUG 0
166#endif
167#if YYDEBUG
168extern int ppdebug;
169#endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000170
Jamie Madill185de882014-12-22 15:17:52 -0500171/* Token type. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000172#ifndef YYTOKENTYPE
173# define YYTOKENTYPE
Jamie Madill185de882014-12-22 15:17:52 -0500174 enum yytokentype
175 {
176 TOK_CONST_INT = 258,
Olli Etuaho809ec542015-08-26 14:30:57 +0300177 TOK_IDENTIFIER = 259,
178 TOK_OP_OR = 260,
179 TOK_OP_AND = 261,
180 TOK_OP_EQ = 262,
181 TOK_OP_NE = 263,
182 TOK_OP_LE = 264,
183 TOK_OP_GE = 265,
184 TOK_OP_LEFT = 266,
185 TOK_OP_RIGHT = 267,
186 TOK_UNARY = 268
Jamie Madill185de882014-12-22 15:17:52 -0500187 };
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000188#endif
189
Jamie Madill185de882014-12-22 15:17:52 -0500190/* Value type. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000191#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
192typedef int YYSTYPE;
193# define YYSTYPE_IS_TRIVIAL 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000194# define YYSTYPE_IS_DECLARED 1
195#endif
196
197
Jamie Madill185de882014-12-22 15:17:52 -0500198
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000199int ppparse (Context *context);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000200
201
202
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000203/* Copy the second part of user declarations. */
204
205
206
207#ifdef short
208# undef short
209#endif
210
211#ifdef YYTYPE_UINT8
212typedef YYTYPE_UINT8 yytype_uint8;
213#else
214typedef unsigned char yytype_uint8;
215#endif
216
217#ifdef YYTYPE_INT8
218typedef YYTYPE_INT8 yytype_int8;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000219#else
Jamie Madill185de882014-12-22 15:17:52 -0500220typedef signed char yytype_int8;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000221#endif
222
223#ifdef YYTYPE_UINT16
224typedef YYTYPE_UINT16 yytype_uint16;
225#else
226typedef unsigned short int yytype_uint16;
227#endif
228
229#ifdef YYTYPE_INT16
230typedef YYTYPE_INT16 yytype_int16;
231#else
232typedef short int yytype_int16;
233#endif
234
235#ifndef YYSIZE_T
236# ifdef __SIZE_TYPE__
237# define YYSIZE_T __SIZE_TYPE__
238# elif defined size_t
239# define YYSIZE_T size_t
Jamie Madill185de882014-12-22 15:17:52 -0500240# elif ! defined YYSIZE_T
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000241# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
242# define YYSIZE_T size_t
243# else
244# define YYSIZE_T unsigned int
245# endif
246#endif
247
248#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
249
250#ifndef YY_
251# if defined YYENABLE_NLS && YYENABLE_NLS
252# if ENABLE_NLS
253# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000254# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000255# endif
256# endif
257# ifndef YY_
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000258# define YY_(Msgid) Msgid
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000259# endif
260#endif
261
Jamie Madill185de882014-12-22 15:17:52 -0500262#ifndef YY_ATTRIBUTE
263# if (defined __GNUC__ \
264 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
265 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
266# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
267# else
268# define YY_ATTRIBUTE(Spec) /* empty */
269# endif
270#endif
271
272#ifndef YY_ATTRIBUTE_PURE
273# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
274#endif
275
276#ifndef YY_ATTRIBUTE_UNUSED
277# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
278#endif
279
280#if !defined _Noreturn \
281 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
282# if defined _MSC_VER && 1200 <= _MSC_VER
283# define _Noreturn __declspec (noreturn)
284# else
285# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400286# endif
287#endif
288
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000289/* Suppress unused-variable warnings by "using" E. */
290#if ! defined lint || defined __GNUC__
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000291# define YYUSE(E) ((void) (E))
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000292#else
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000293# define YYUSE(E) /* empty */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000294#endif
295
Jamie Madill185de882014-12-22 15:17:52 -0500296#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
297/* Suppress an incorrect diagnostic about yylval being uninitialized. */
298# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
299 _Pragma ("GCC diagnostic push") \
300 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
301 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
302# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
303 _Pragma ("GCC diagnostic pop")
304#else
305# define YY_INITIAL_VALUE(Value) Value
306#endif
307#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
308# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
309# define YY_IGNORE_MAYBE_UNINITIALIZED_END
310#endif
311#ifndef YY_INITIAL_VALUE
312# define YY_INITIAL_VALUE(Value) /* Nothing. */
313#endif
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400314
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000315
316#if ! defined yyoverflow || YYERROR_VERBOSE
317
318/* The parser invokes alloca or malloc; define the necessary symbols. */
319
320# ifdef YYSTACK_USE_ALLOCA
321# if YYSTACK_USE_ALLOCA
322# ifdef __GNUC__
323# define YYSTACK_ALLOC __builtin_alloca
324# elif defined __BUILTIN_VA_ARG_INCR
325# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
326# elif defined _AIX
327# define YYSTACK_ALLOC __alloca
328# elif defined _MSC_VER
329# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
330# define alloca _alloca
331# else
332# define YYSTACK_ALLOC alloca
Jamie Madill185de882014-12-22 15:17:52 -0500333# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000334# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000335 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
336# ifndef EXIT_SUCCESS
337# define EXIT_SUCCESS 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000338# endif
339# endif
340# endif
341# endif
342# endif
343
344# ifdef YYSTACK_ALLOC
Jamie Madill185de882014-12-22 15:17:52 -0500345 /* Pacify GCC's 'empty if-body' warning. */
346# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000347# ifndef YYSTACK_ALLOC_MAXIMUM
348 /* The OS might guarantee only one guard page at the bottom of the stack,
349 and a page size can be as small as 4096 bytes. So we cannot safely
350 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
351 to allow for a few compiler-allocated temporary stack slots. */
352# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
353# endif
354# else
355# define YYSTACK_ALLOC YYMALLOC
356# define YYSTACK_FREE YYFREE
357# ifndef YYSTACK_ALLOC_MAXIMUM
358# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
359# endif
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000360# if (defined __cplusplus && ! defined EXIT_SUCCESS \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000361 && ! ((defined YYMALLOC || defined malloc) \
Jamie Madill185de882014-12-22 15:17:52 -0500362 && (defined YYFREE || defined free)))
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000363# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000364# ifndef EXIT_SUCCESS
365# define EXIT_SUCCESS 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000366# endif
367# endif
368# ifndef YYMALLOC
369# define YYMALLOC malloc
Jamie Madill185de882014-12-22 15:17:52 -0500370# if ! defined malloc && ! defined EXIT_SUCCESS
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000371void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
372# endif
373# endif
374# ifndef YYFREE
375# define YYFREE free
Jamie Madill185de882014-12-22 15:17:52 -0500376# if ! defined free && ! defined EXIT_SUCCESS
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000377void free (void *); /* INFRINGES ON USER NAME SPACE */
378# endif
379# endif
380# endif
381#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
382
383
384#if (! defined yyoverflow \
385 && (! defined __cplusplus \
Jamie Madill185de882014-12-22 15:17:52 -0500386 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000387
388/* A type that is properly aligned for any stack member. */
389union yyalloc
390{
391 yytype_int16 yyss_alloc;
392 YYSTYPE yyvs_alloc;
393};
394
395/* The size of the maximum gap between one aligned stack and the next. */
396# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
397
398/* The size of an array large to enough to hold all stacks, each with
399 N elements. */
400# define YYSTACK_BYTES(N) \
401 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
402 + YYSTACK_GAP_MAXIMUM)
403
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000404# define YYCOPY_NEEDED 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000405
406/* Relocate STACK from its old location to the new one. The
407 local variables YYSIZE and YYSTACKSIZE give the old and new number of
408 elements in the stack, and YYPTR gives the new location of the
409 stack. Advance YYPTR to a properly aligned location for the next
410 stack. */
Jamie Madill185de882014-12-22 15:17:52 -0500411# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
412 do \
413 { \
414 YYSIZE_T yynewbytes; \
415 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
416 Stack = &yyptr->Stack_alloc; \
417 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
418 yyptr += yynewbytes / sizeof (*yyptr); \
419 } \
420 while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000421
422#endif
423
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000424#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
425/* Copy COUNT objects from SRC to DST. The source and destination do
426 not overlap. */
427# ifndef YYCOPY
428# if defined __GNUC__ && 1 < __GNUC__
429# define YYCOPY(Dst, Src, Count) \
430 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
431# else
432# define YYCOPY(Dst, Src, Count) \
433 do \
434 { \
435 YYSIZE_T yyi; \
436 for (yyi = 0; yyi < (Count); yyi++) \
437 (Dst)[yyi] = (Src)[yyi]; \
438 } \
Jamie Madill185de882014-12-22 15:17:52 -0500439 while (0)
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000440# endif
441# endif
442#endif /* !YYCOPY_NEEDED */
443
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000444/* YYFINAL -- State number of the termination state. */
Olli Etuaho809ec542015-08-26 14:30:57 +0300445#define YYFINAL 15
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000446/* YYLAST -- Last index in YYTABLE. */
Olli Etuaho809ec542015-08-26 14:30:57 +0300447#define YYLAST 176
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000448
449/* YYNTOKENS -- Number of terminals. */
Olli Etuaho809ec542015-08-26 14:30:57 +0300450#define YYNTOKENS 28
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000451/* YYNNTS -- Number of nonterminals. */
Olli Etuaho809ec542015-08-26 14:30:57 +0300452#define YYNNTS 5
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000453/* YYNRULES -- Number of rules. */
Olli Etuaho809ec542015-08-26 14:30:57 +0300454#define YYNRULES 29
Jamie Madill185de882014-12-22 15:17:52 -0500455/* YYNSTATES -- Number of states. */
Olli Etuaho809ec542015-08-26 14:30:57 +0300456#define YYNSTATES 55
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000457
Jamie Madill185de882014-12-22 15:17:52 -0500458/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
459 by yylex, with out-of-bounds checking. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000460#define YYUNDEFTOK 2
Olli Etuaho809ec542015-08-26 14:30:57 +0300461#define YYMAXUTOK 268
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000462
Jamie Madill185de882014-12-22 15:17:52 -0500463#define YYTRANSLATE(YYX) \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000464 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
465
Jamie Madill185de882014-12-22 15:17:52 -0500466/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
467 as returned by yylex, without out-of-bounds checking. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000468static const yytype_uint8 yytranslate[] =
469{
470 0, 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,
Olli Etuaho809ec542015-08-26 14:30:57 +0300473 2, 2, 2, 24, 2, 2, 2, 22, 9, 2,
474 26, 27, 20, 18, 2, 19, 2, 21, 2, 2,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Olli Etuaho809ec542015-08-26 14:30:57 +0300476 12, 2, 13, 2, 2, 2, 2, 2, 2, 2,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Olli Etuaho809ec542015-08-26 14:30:57 +0300479 2, 2, 2, 2, 8, 2, 2, 2, 2, 2,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Olli Etuaho809ec542015-08-26 14:30:57 +0300482 2, 2, 2, 2, 7, 2, 25, 2, 2, 2,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000483 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, 2, 2, 2, 2,
494 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
Olli Etuaho809ec542015-08-26 14:30:57 +0300496 5, 6, 10, 11, 14, 15, 16, 17, 23
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000497};
498
499#if YYDEBUG
Jamie Madill185de882014-12-22 15:17:52 -0500500 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
Geoff Lang93561c32016-09-20 10:22:55 -0400501static const yytype_uint16 yyrline[] =
502{
503 0, 110, 110, 117, 118, 129, 129, 150, 150, 171,
504 174, 177, 180, 183, 186, 189, 192, 195, 198, 218,
505 238, 241, 244, 264, 284, 287, 290, 293, 296, 299
506};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000507#endif
508
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000509#if YYDEBUG || YYERROR_VERBOSE || 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000510/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
511 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
512static const char *const yytname[] =
513{
Olli Etuaho809ec542015-08-26 14:30:57 +0300514 "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_IDENTIFIER",
515 "TOK_OP_OR", "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_EQ", "TOK_OP_NE",
516 "'<'", "'>'", "TOK_OP_LE", "TOK_OP_GE", "TOK_OP_LEFT", "TOK_OP_RIGHT",
517 "'+'", "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('",
518 "')'", "$accept", "input", "expression", "$@1", "$@2", YY_NULLPTR
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000519};
520#endif
521
522# ifdef YYPRINT
Jamie Madill185de882014-12-22 15:17:52 -0500523/* YYTOKNUM[NUM] -- (External) token number corresponding to the
524 (internal) symbol number NUM (which must be that of a token). */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000525static const yytype_uint16 yytoknum[] =
526{
Olli Etuaho809ec542015-08-26 14:30:57 +0300527 0, 256, 257, 258, 259, 260, 261, 124, 94, 38,
528 262, 263, 60, 62, 264, 265, 266, 267, 43, 45,
529 42, 47, 37, 268, 33, 126, 40, 41
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000530};
531# endif
532
Olli Etuaho809ec542015-08-26 14:30:57 +0300533#define YYPACT_NINF -12
Jamie Madill185de882014-12-22 15:17:52 -0500534
535#define yypact_value_is_default(Yystate) \
Olli Etuaho809ec542015-08-26 14:30:57 +0300536 (!!((Yystate) == (-12)))
Jamie Madill185de882014-12-22 15:17:52 -0500537
538#define YYTABLE_NINF -1
539
540#define yytable_value_is_error(Yytable_value) \
541 0
542
543 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
544 STATE-NUM. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000545static const yytype_int16 yypact[] =
546{
Olli Etuaho809ec542015-08-26 14:30:57 +0300547 31, -12, -12, 31, 31, 31, 31, 31, 51, 76,
548 -12, -12, -12, -12, 53, -12, -12, -12, 31, 31,
549 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
550 31, 31, 31, 31, -12, 31, 31, 124, 138, 26,
551 149, 149, -11, -11, -11, -11, 154, 154, -8, -8,
552 -12, -12, -12, 93, 109
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000553};
554
Jamie Madill185de882014-12-22 15:17:52 -0500555 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
556 Performed when YYTABLE does not specify something else to do. Zero
557 means the default is an error. */
558static const yytype_uint8 yydefact[] =
559{
Olli Etuaho809ec542015-08-26 14:30:57 +0300560 0, 3, 4, 0, 0, 0, 0, 0, 0, 2,
561 28, 27, 25, 26, 0, 1, 5, 7, 0, 0,
Jamie Madill185de882014-12-22 15:17:52 -0500562 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Olli Etuaho809ec542015-08-26 14:30:57 +0300563 0, 0, 0, 0, 29, 0, 0, 9, 10, 11,
564 13, 12, 17, 16, 15, 14, 19, 18, 21, 20,
565 24, 23, 22, 6, 8
Jamie Madill185de882014-12-22 15:17:52 -0500566};
567
568 /* YYPGOTO[NTERM-NUM]. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000569static const yytype_int8 yypgoto[] =
570{
Olli Etuaho809ec542015-08-26 14:30:57 +0300571 -12, -12, -3, -12, -12
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000572};
573
Jamie Madill185de882014-12-22 15:17:52 -0500574 /* YYDEFGOTO[NTERM-NUM]. */
575static const yytype_int8 yydefgoto[] =
576{
Olli Etuaho809ec542015-08-26 14:30:57 +0300577 -1, 8, 9, 35, 36
Jamie Madill185de882014-12-22 15:17:52 -0500578};
579
580 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
581 positive, shift that token. If negative, reduce the rule whose
582 number is the opposite. If YYTABLE_NINF, syntax error. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000583static const yytype_uint8 yytable[] =
584{
Olli Etuaho809ec542015-08-26 14:30:57 +0300585 10, 11, 12, 13, 14, 27, 28, 29, 30, 31,
586 32, 33, 31, 32, 33, 37, 38, 39, 40, 41,
587 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
588 52, 0, 53, 54, 1, 2, 21, 22, 23, 24,
589 25, 26, 27, 28, 29, 30, 31, 32, 33, 3,
590 4, 15, 0, 0, 0, 5, 6, 7, 16, 17,
591 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
592 28, 29, 30, 31, 32, 33, 0, 0, 0, 0,
593 34, 16, 17, 18, 19, 20, 21, 22, 23, 24,
594 25, 26, 27, 28, 29, 30, 31, 32, 33, 17,
595 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
596 28, 29, 30, 31, 32, 33, 18, 19, 20, 21,
597 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
598 32, 33, 19, 20, 21, 22, 23, 24, 25, 26,
599 27, 28, 29, 30, 31, 32, 33, 20, 21, 22,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000600 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
Olli Etuaho809ec542015-08-26 14:30:57 +0300601 33, 23, 24, 25, 26, 27, 28, 29, 30, 31,
602 32, 33, 29, 30, 31, 32, 33
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000603};
604
605static const yytype_int8 yycheck[] =
606{
Olli Etuaho809ec542015-08-26 14:30:57 +0300607 3, 4, 5, 6, 7, 16, 17, 18, 19, 20,
608 21, 22, 20, 21, 22, 18, 19, 20, 21, 22,
609 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
610 33, -1, 35, 36, 3, 4, 10, 11, 12, 13,
611 14, 15, 16, 17, 18, 19, 20, 21, 22, 18,
612 19, 0, -1, -1, -1, 24, 25, 26, 5, 6,
613 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
614 17, 18, 19, 20, 21, 22, -1, -1, -1, -1,
615 27, 5, 6, 7, 8, 9, 10, 11, 12, 13,
616 14, 15, 16, 17, 18, 19, 20, 21, 22, 6,
617 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
618 17, 18, 19, 20, 21, 22, 7, 8, 9, 10,
619 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
620 21, 22, 8, 9, 10, 11, 12, 13, 14, 15,
621 16, 17, 18, 19, 20, 21, 22, 9, 10, 11,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000622 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Olli Etuaho809ec542015-08-26 14:30:57 +0300623 22, 12, 13, 14, 15, 16, 17, 18, 19, 20,
624 21, 22, 18, 19, 20, 21, 22
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000625};
626
Jamie Madill185de882014-12-22 15:17:52 -0500627 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
628 symbol of state STATE-NUM. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000629static const yytype_uint8 yystos[] =
630{
Olli Etuaho809ec542015-08-26 14:30:57 +0300631 0, 3, 4, 18, 19, 24, 25, 26, 29, 30,
632 30, 30, 30, 30, 30, 0, 5, 6, 7, 8,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000633 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Olli Etuaho809ec542015-08-26 14:30:57 +0300634 19, 20, 21, 22, 27, 31, 32, 30, 30, 30,
635 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
636 30, 30, 30, 30, 30
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000637};
638
Jamie Madill185de882014-12-22 15:17:52 -0500639 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
640static const yytype_uint8 yyr1[] =
641{
Olli Etuaho809ec542015-08-26 14:30:57 +0300642 0, 28, 29, 30, 30, 31, 30, 32, 30, 30,
643 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
644 30, 30, 30, 30, 30, 30, 30, 30, 30, 30
Jamie Madill185de882014-12-22 15:17:52 -0500645};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000646
Jamie Madill185de882014-12-22 15:17:52 -0500647 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
648static const yytype_uint8 yyr2[] =
649{
Olli Etuaho809ec542015-08-26 14:30:57 +0300650 0, 2, 1, 1, 1, 0, 4, 0, 4, 3,
Jamie Madill185de882014-12-22 15:17:52 -0500651 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Olli Etuaho809ec542015-08-26 14:30:57 +0300652 3, 3, 3, 3, 3, 2, 2, 2, 2, 3
Jamie Madill185de882014-12-22 15:17:52 -0500653};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000654
655
Jamie Madill185de882014-12-22 15:17:52 -0500656#define yyerrok (yyerrstatus = 0)
657#define yyclearin (yychar = YYEMPTY)
658#define YYEMPTY (-2)
659#define YYEOF 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000660
Jamie Madill185de882014-12-22 15:17:52 -0500661#define YYACCEPT goto yyacceptlab
662#define YYABORT goto yyabortlab
663#define YYERROR goto yyerrorlab
664
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000665
666#define YYRECOVERING() (!!yyerrstatus)
667
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000668#define YYBACKUP(Token, Value) \
669do \
670 if (yychar == YYEMPTY) \
671 { \
672 yychar = (Token); \
673 yylval = (Value); \
674 YYPOPSTACK (yylen); \
675 yystate = *yyssp; \
676 goto yybackup; \
677 } \
678 else \
679 { \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000680 yyerror (context, YY_("syntax error: cannot back up")); \
Jamie Madill185de882014-12-22 15:17:52 -0500681 YYERROR; \
682 } \
683while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000684
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000685/* Error token number */
Jamie Madill185de882014-12-22 15:17:52 -0500686#define YYTERROR 1
687#define YYERRCODE 256
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000688
689
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000690
691/* Enable debugging if requested. */
692#if YYDEBUG
693
694# ifndef YYFPRINTF
695# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
696# define YYFPRINTF fprintf
697# endif
698
Jamie Madill185de882014-12-22 15:17:52 -0500699# define YYDPRINTF(Args) \
700do { \
701 if (yydebug) \
702 YYFPRINTF Args; \
703} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000704
Jamie Madill185de882014-12-22 15:17:52 -0500705/* This macro is provided for backward compatibility. */
706#ifndef YY_LOCATION_PRINT
707# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
708#endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000709
710
Jamie Madill185de882014-12-22 15:17:52 -0500711# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
712do { \
713 if (yydebug) \
714 { \
715 YYFPRINTF (stderr, "%s ", Title); \
716 yy_symbol_print (stderr, \
717 Type, Value, context); \
718 YYFPRINTF (stderr, "\n"); \
719 } \
720} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000721
Jamie Madill185de882014-12-22 15:17:52 -0500722
723/*----------------------------------------.
724| Print this symbol's value on YYOUTPUT. |
725`----------------------------------------*/
726
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000727static void
728yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000729{
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000730 FILE *yyo = yyoutput;
731 YYUSE (yyo);
Jamie Madill185de882014-12-22 15:17:52 -0500732 YYUSE (context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000733 if (!yyvaluep)
734 return;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000735# ifdef YYPRINT
736 if (yytype < YYNTOKENS)
737 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000738# endif
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400739 YYUSE (yytype);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000740}
741
742
743/*--------------------------------.
744| Print this symbol on YYOUTPUT. |
745`--------------------------------*/
746
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000747static void
748yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000749{
Jamie Madill185de882014-12-22 15:17:52 -0500750 YYFPRINTF (yyoutput, "%s %s (",
751 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000752
753 yy_symbol_value_print (yyoutput, yytype, yyvaluep, context);
754 YYFPRINTF (yyoutput, ")");
755}
756
757/*------------------------------------------------------------------.
758| yy_stack_print -- Print the state stack from its BOTTOM up to its |
759| TOP (included). |
760`------------------------------------------------------------------*/
761
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000762static void
763yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000764{
765 YYFPRINTF (stderr, "Stack now");
766 for (; yybottom <= yytop; yybottom++)
767 {
768 int yybot = *yybottom;
769 YYFPRINTF (stderr, " %d", yybot);
770 }
771 YYFPRINTF (stderr, "\n");
772}
773
Jamie Madill185de882014-12-22 15:17:52 -0500774# define YY_STACK_PRINT(Bottom, Top) \
775do { \
776 if (yydebug) \
777 yy_stack_print ((Bottom), (Top)); \
778} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000779
780
781/*------------------------------------------------.
782| Report that the YYRULE is going to be reduced. |
783`------------------------------------------------*/
784
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000785static void
Jamie Madill185de882014-12-22 15:17:52 -0500786yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000787{
Jamie Madill185de882014-12-22 15:17:52 -0500788 unsigned long int yylno = yyrline[yyrule];
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000789 int yynrhs = yyr2[yyrule];
790 int yyi;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000791 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
Jamie Madill185de882014-12-22 15:17:52 -0500792 yyrule - 1, yylno);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000793 /* The symbols being reduced. */
794 for (yyi = 0; yyi < yynrhs; yyi++)
795 {
796 YYFPRINTF (stderr, " $%d = ", yyi + 1);
Jamie Madill185de882014-12-22 15:17:52 -0500797 yy_symbol_print (stderr,
798 yystos[yyssp[yyi + 1 - yynrhs]],
799 &(yyvsp[(yyi + 1) - (yynrhs)])
800 , context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000801 YYFPRINTF (stderr, "\n");
802 }
803}
804
Jamie Madill185de882014-12-22 15:17:52 -0500805# define YY_REDUCE_PRINT(Rule) \
806do { \
807 if (yydebug) \
808 yy_reduce_print (yyssp, yyvsp, Rule, context); \
809} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000810
811/* Nonzero means print parse trace. It is left uninitialized so that
812 multiple parsers can coexist. */
813int yydebug;
814#else /* !YYDEBUG */
815# define YYDPRINTF(Args)
816# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
817# define YY_STACK_PRINT(Bottom, Top)
818# define YY_REDUCE_PRINT(Rule)
819#endif /* !YYDEBUG */
820
821
822/* YYINITDEPTH -- initial size of the parser's stacks. */
Jamie Madill185de882014-12-22 15:17:52 -0500823#ifndef YYINITDEPTH
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000824# define YYINITDEPTH 200
825#endif
826
827/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
828 if the built-in stack extension method is used).
829
830 Do not make this value too large; the results are undefined if
831 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
832 evaluated with infinite-precision integer arithmetic. */
833
834#ifndef YYMAXDEPTH
835# define YYMAXDEPTH 10000
836#endif
837
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000838
839#if YYERROR_VERBOSE
840
841# ifndef yystrlen
842# if defined __GLIBC__ && defined _STRING_H
843# define yystrlen strlen
844# else
845/* Return the length of YYSTR. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000846static YYSIZE_T
847yystrlen (const char *yystr)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000848{
849 YYSIZE_T yylen;
850 for (yylen = 0; yystr[yylen]; yylen++)
851 continue;
852 return yylen;
853}
854# endif
855# endif
856
857# ifndef yystpcpy
858# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
859# define yystpcpy stpcpy
860# else
861/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
862 YYDEST. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000863static char *
864yystpcpy (char *yydest, const char *yysrc)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000865{
866 char *yyd = yydest;
867 const char *yys = yysrc;
868
869 while ((*yyd++ = *yys++) != '\0')
870 continue;
871
872 return yyd - 1;
873}
874# endif
875# endif
876
877# ifndef yytnamerr
878/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
879 quotes and backslashes, so that it's suitable for yyerror. The
880 heuristic is that double-quoting is unnecessary unless the string
881 contains an apostrophe, a comma, or backslash (other than
882 backslash-backslash). YYSTR is taken from yytname. If YYRES is
883 null, do not copy; instead, return the length of what the result
884 would have been. */
885static YYSIZE_T
886yytnamerr (char *yyres, const char *yystr)
887{
888 if (*yystr == '"')
889 {
890 YYSIZE_T yyn = 0;
891 char const *yyp = yystr;
892
893 for (;;)
Jamie Madill185de882014-12-22 15:17:52 -0500894 switch (*++yyp)
895 {
896 case '\'':
897 case ',':
898 goto do_not_strip_quotes;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000899
Jamie Madill185de882014-12-22 15:17:52 -0500900 case '\\':
901 if (*++yyp != '\\')
902 goto do_not_strip_quotes;
903 /* Fall through. */
904 default:
905 if (yyres)
906 yyres[yyn] = *yyp;
907 yyn++;
908 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000909
Jamie Madill185de882014-12-22 15:17:52 -0500910 case '"':
911 if (yyres)
912 yyres[yyn] = '\0';
913 return yyn;
914 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000915 do_not_strip_quotes: ;
916 }
917
918 if (! yyres)
919 return yystrlen (yystr);
920
921 return yystpcpy (yyres, yystr) - yyres;
922}
923# endif
924
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000925/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
926 about the unexpected token YYTOKEN for the state stack whose top is
927 YYSSP.
928
929 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
930 not large enough to hold the message. In that case, also set
931 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
932 required number of bytes is too large to store. */
933static int
934yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
935 yytype_int16 *yyssp, int yytoken)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000936{
Jamie Madill185de882014-12-22 15:17:52 -0500937 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000938 YYSIZE_T yysize = yysize0;
939 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
940 /* Internationalized format string. */
Jamie Madill185de882014-12-22 15:17:52 -0500941 const char *yyformat = YY_NULLPTR;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000942 /* Arguments of yyformat. */
943 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
944 /* Number of reported tokens (one for the "unexpected", one per
945 "expected"). */
946 int yycount = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000947
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000948 /* There are many possibilities here to consider:
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000949 - If this state is a consistent state with a default action, then
950 the only way this function was invoked is if the default action
951 is an error action. In that case, don't check for expected
952 tokens because there are none.
953 - The only way there can be no lookahead present (in yychar) is if
954 this state is a consistent state with a default action. Thus,
955 detecting the absence of a lookahead is sufficient to determine
956 that there is no unexpected or expected token to report. In that
957 case, just report a simple "syntax error".
958 - Don't assume there isn't a lookahead just because this state is a
959 consistent state with a default action. There might have been a
960 previous inconsistent state, consistent state with a non-default
961 action, or user semantic action that manipulated yychar.
962 - Of course, the expected token list depends on states to have
963 correct lookahead information, and it depends on the parser not
964 to perform extra reductions after fetching a lookahead from the
965 scanner and before detecting a syntax error. Thus, state merging
966 (from LALR or IELR) and default reductions corrupt the expected
967 token list. However, the list is correct for canonical LR with
968 one exception: it will still contain any token that will not be
969 accepted due to an error action in a later state.
970 */
971 if (yytoken != YYEMPTY)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000972 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000973 int yyn = yypact[*yyssp];
974 yyarg[yycount++] = yytname[yytoken];
975 if (!yypact_value_is_default (yyn))
976 {
977 /* Start YYX at -YYN if negative to avoid negative indexes in
978 YYCHECK. In other words, skip the first -YYN actions for
979 this state because they are default actions. */
980 int yyxbegin = yyn < 0 ? -yyn : 0;
981 /* Stay within bounds of both yycheck and yytname. */
982 int yychecklim = YYLAST - yyn + 1;
983 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
984 int yyx;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000985
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000986 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
987 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
988 && !yytable_value_is_error (yytable[yyx + yyn]))
989 {
990 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
991 {
992 yycount = 1;
993 yysize = yysize0;
994 break;
995 }
996 yyarg[yycount++] = yytname[yyx];
997 {
Jamie Madill185de882014-12-22 15:17:52 -0500998 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000999 if (! (yysize <= yysize1
1000 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1001 return 2;
1002 yysize = yysize1;
1003 }
1004 }
1005 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001006 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001007
1008 switch (yycount)
1009 {
1010# define YYCASE_(N, S) \
1011 case N: \
1012 yyformat = S; \
1013 break
1014 YYCASE_(0, YY_("syntax error"));
1015 YYCASE_(1, YY_("syntax error, unexpected %s"));
1016 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1017 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1018 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1019 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1020# undef YYCASE_
1021 }
1022
1023 {
1024 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1025 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1026 return 2;
1027 yysize = yysize1;
1028 }
1029
1030 if (*yymsg_alloc < yysize)
1031 {
1032 *yymsg_alloc = 2 * yysize;
1033 if (! (yysize <= *yymsg_alloc
1034 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1035 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1036 return 1;
1037 }
1038
1039 /* Avoid sprintf, as that infringes on the user's name space.
1040 Don't have undefined behavior even if the translation
1041 produced a string with the wrong number of "%s"s. */
1042 {
1043 char *yyp = *yymsg;
1044 int yyi = 0;
1045 while ((*yyp = *yyformat) != '\0')
1046 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1047 {
1048 yyp += yytnamerr (yyp, yyarg[yyi++]);
1049 yyformat += 2;
1050 }
1051 else
1052 {
1053 yyp++;
1054 yyformat++;
1055 }
1056 }
1057 return 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001058}
1059#endif /* YYERROR_VERBOSE */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001060
1061/*-----------------------------------------------.
1062| Release the memory associated to this symbol. |
1063`-----------------------------------------------*/
1064
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001065static void
1066yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001067{
1068 YYUSE (yyvaluep);
1069 YYUSE (context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001070 if (!yymsg)
1071 yymsg = "Deleting";
1072 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1073
Jamie Madill185de882014-12-22 15:17:52 -05001074 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001075 YYUSE (yytype);
Jamie Madill185de882014-12-22 15:17:52 -05001076 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001077}
1078
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001079
1080
1081
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001082/*----------.
1083| yyparse. |
1084`----------*/
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001085
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001086int
1087yyparse (Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001088{
1089/* The lookahead symbol. */
1090int yychar;
1091
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001092
Jamie Madill185de882014-12-22 15:17:52 -05001093/* The semantic value of the lookahead symbol. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001094/* Default value used for initialization, for pacifying older GCCs
1095 or non-GCC compilers. */
Jamie Madill185de882014-12-22 15:17:52 -05001096YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1097YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001098
1099 /* Number of syntax errors so far. */
1100 int yynerrs;
1101
1102 int yystate;
1103 /* Number of tokens to shift before error messages enabled. */
1104 int yyerrstatus;
1105
1106 /* The stacks and their tools:
Jamie Madill185de882014-12-22 15:17:52 -05001107 'yyss': related to states.
1108 'yyvs': related to semantic values.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001109
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001110 Refer to the stacks through separate pointers, to allow yyoverflow
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001111 to reallocate them elsewhere. */
1112
1113 /* The state stack. */
1114 yytype_int16 yyssa[YYINITDEPTH];
1115 yytype_int16 *yyss;
1116 yytype_int16 *yyssp;
1117
1118 /* The semantic value stack. */
1119 YYSTYPE yyvsa[YYINITDEPTH];
1120 YYSTYPE *yyvs;
1121 YYSTYPE *yyvsp;
1122
1123 YYSIZE_T yystacksize;
1124
1125 int yyn;
1126 int yyresult;
1127 /* Lookahead token as an internal (translated) token number. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001128 int yytoken = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001129 /* The variables used to return semantic value and location from the
1130 action routines. */
1131 YYSTYPE yyval;
1132
1133#if YYERROR_VERBOSE
1134 /* Buffer for error messages, and its allocated size. */
1135 char yymsgbuf[128];
1136 char *yymsg = yymsgbuf;
1137 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1138#endif
1139
1140#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1141
1142 /* The number of symbols on the RHS of the reduced rule.
1143 Keep to zero when no symbol should be popped. */
1144 int yylen = 0;
1145
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001146 yyssp = yyss = yyssa;
1147 yyvsp = yyvs = yyvsa;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001148 yystacksize = YYINITDEPTH;
1149
1150 YYDPRINTF ((stderr, "Starting parse\n"));
1151
1152 yystate = 0;
1153 yyerrstatus = 0;
1154 yynerrs = 0;
1155 yychar = YYEMPTY; /* Cause a token to be read. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001156 goto yysetstate;
1157
1158/*------------------------------------------------------------.
1159| yynewstate -- Push a new state, which is found in yystate. |
1160`------------------------------------------------------------*/
1161 yynewstate:
1162 /* In all cases, when you get here, the value and location stacks
1163 have just been pushed. So pushing a state here evens the stacks. */
1164 yyssp++;
1165
1166 yysetstate:
1167 *yyssp = yystate;
1168
1169 if (yyss + yystacksize - 1 <= yyssp)
1170 {
1171 /* Get the current used size of the three stacks, in elements. */
1172 YYSIZE_T yysize = yyssp - yyss + 1;
1173
1174#ifdef yyoverflow
1175 {
Jamie Madill185de882014-12-22 15:17:52 -05001176 /* Give user a chance to reallocate the stack. Use copies of
1177 these so that the &'s don't force the real ones into
1178 memory. */
1179 YYSTYPE *yyvs1 = yyvs;
1180 yytype_int16 *yyss1 = yyss;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001181
Jamie Madill185de882014-12-22 15:17:52 -05001182 /* Each stack pointer address is followed by the size of the
1183 data in use in that stack, in bytes. This used to be a
1184 conditional around just the two extra args, but that might
1185 be undefined if yyoverflow is a macro. */
1186 yyoverflow (YY_("memory exhausted"),
1187 &yyss1, yysize * sizeof (*yyssp),
1188 &yyvs1, yysize * sizeof (*yyvsp),
1189 &yystacksize);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001190
Jamie Madill185de882014-12-22 15:17:52 -05001191 yyss = yyss1;
1192 yyvs = yyvs1;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001193 }
1194#else /* no yyoverflow */
1195# ifndef YYSTACK_RELOCATE
1196 goto yyexhaustedlab;
1197# else
1198 /* Extend the stack our own way. */
1199 if (YYMAXDEPTH <= yystacksize)
Jamie Madill185de882014-12-22 15:17:52 -05001200 goto yyexhaustedlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001201 yystacksize *= 2;
1202 if (YYMAXDEPTH < yystacksize)
Jamie Madill185de882014-12-22 15:17:52 -05001203 yystacksize = YYMAXDEPTH;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001204
1205 {
Jamie Madill185de882014-12-22 15:17:52 -05001206 yytype_int16 *yyss1 = yyss;
1207 union yyalloc *yyptr =
1208 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1209 if (! yyptr)
1210 goto yyexhaustedlab;
1211 YYSTACK_RELOCATE (yyss_alloc, yyss);
1212 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001213# undef YYSTACK_RELOCATE
Jamie Madill185de882014-12-22 15:17:52 -05001214 if (yyss1 != yyssa)
1215 YYSTACK_FREE (yyss1);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001216 }
1217# endif
1218#endif /* no yyoverflow */
1219
1220 yyssp = yyss + yysize - 1;
1221 yyvsp = yyvs + yysize - 1;
1222
1223 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
Jamie Madill185de882014-12-22 15:17:52 -05001224 (unsigned long int) yystacksize));
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001225
1226 if (yyss + yystacksize - 1 <= yyssp)
Jamie Madill185de882014-12-22 15:17:52 -05001227 YYABORT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001228 }
1229
1230 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1231
1232 if (yystate == YYFINAL)
1233 YYACCEPT;
1234
1235 goto yybackup;
1236
1237/*-----------.
1238| yybackup. |
1239`-----------*/
1240yybackup:
1241
1242 /* Do appropriate processing given the current state. Read a
1243 lookahead token if we need one and don't already have one. */
1244
1245 /* First try to decide what to do without reference to lookahead token. */
1246 yyn = yypact[yystate];
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001247 if (yypact_value_is_default (yyn))
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001248 goto yydefault;
1249
1250 /* Not known => get a lookahead token if don't already have one. */
1251
1252 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1253 if (yychar == YYEMPTY)
1254 {
1255 YYDPRINTF ((stderr, "Reading a token: "));
Jamie Madill185de882014-12-22 15:17:52 -05001256 yychar = yylex (&yylval, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001257 }
1258
1259 if (yychar <= YYEOF)
1260 {
1261 yychar = yytoken = YYEOF;
1262 YYDPRINTF ((stderr, "Now at end of input.\n"));
1263 }
1264 else
1265 {
1266 yytoken = YYTRANSLATE (yychar);
1267 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1268 }
1269
1270 /* If the proper action on seeing token YYTOKEN is to reduce or to
1271 detect an error, take that action. */
1272 yyn += yytoken;
1273 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1274 goto yydefault;
1275 yyn = yytable[yyn];
1276 if (yyn <= 0)
1277 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001278 if (yytable_value_is_error (yyn))
1279 goto yyerrlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001280 yyn = -yyn;
1281 goto yyreduce;
1282 }
1283
1284 /* Count tokens shifted since error; after three, turn off error
1285 status. */
1286 if (yyerrstatus)
1287 yyerrstatus--;
1288
1289 /* Shift the lookahead token. */
1290 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1291
1292 /* Discard the shifted token. */
1293 yychar = YYEMPTY;
1294
1295 yystate = yyn;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001296 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001297 *++yyvsp = yylval;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001298 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001299
1300 goto yynewstate;
1301
1302
1303/*-----------------------------------------------------------.
1304| yydefault -- do the default action for the current state. |
1305`-----------------------------------------------------------*/
1306yydefault:
1307 yyn = yydefact[yystate];
1308 if (yyn == 0)
1309 goto yyerrlab;
1310 goto yyreduce;
1311
1312
1313/*-----------------------------.
1314| yyreduce -- Do a reduction. |
1315`-----------------------------*/
1316yyreduce:
1317 /* yyn is the number of a rule to reduce with. */
1318 yylen = yyr2[yyn];
1319
1320 /* If YYLEN is nonzero, implement the default value of the action:
Jamie Madill185de882014-12-22 15:17:52 -05001321 '$$ = $1'.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001322
1323 Otherwise, the following line sets YYVAL to garbage.
1324 This behavior is undocumented and Bison
1325 users should not rely upon it. Assigning to YYVAL
1326 unconditionally makes the parser a bit smaller, and it avoids a
1327 GCC warning that YYVAL may be used uninitialized. */
1328 yyval = yyvsp[1-yylen];
1329
1330
1331 YY_REDUCE_PRINT (yyn);
1332 switch (yyn)
1333 {
1334 case 2:
1335
1336 {
Jamie Madill185de882014-12-22 15:17:52 -05001337 *(context->result) = static_cast<int>((yyvsp[0]));
Olli Etuaho3187a382015-09-09 12:00:12 +03001338 YYACCEPT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001339 }
Jamie Madill185de882014-12-22 15:17:52 -05001340
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001341 break;
1342
1343 case 4:
1344
1345 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001346 if (!context->isIgnoringErrors())
1347 {
Olli Etuaho3187a382015-09-09 12:00:12 +03001348 // This rule should be applied right after the token is lexed, so we can
1349 // refer to context->token in the error message.
Olli Etuaho247374c2015-09-09 15:07:24 +03001350 context->diagnostics->report(context->errorSettings.unexpectedIdentifier,
Olli Etuaho3187a382015-09-09 12:00:12 +03001351 context->token->location, context->token->text);
Olli Etuaho247374c2015-09-09 15:07:24 +03001352 *(context->valid) = false;
Olli Etuaho809ec542015-08-26 14:30:57 +03001353 }
Olli Etuaho3187a382015-09-09 12:00:12 +03001354 (yyval) = (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001355 }
Jamie Madill185de882014-12-22 15:17:52 -05001356
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001357 break;
1358
1359 case 5:
1360
1361 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001362 if ((yyvsp[-1]) != 0)
1363 {
1364 // Ignore errors in the short-circuited part of the expression.
1365 // ESSL3.00 section 3.4:
1366 // If an operand is not evaluated, the presence of undefined identifiers
1367 // in the operand will not cause an error.
1368 // Unevaluated division by zero should not cause an error either.
1369 context->startIgnoreErrors();
1370 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001371 }
Jamie Madill185de882014-12-22 15:17:52 -05001372
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001373 break;
1374
1375 case 6:
1376
1377 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001378 if ((yyvsp[-3]) != 0)
1379 {
1380 context->endIgnoreErrors();
1381 (yyval) = static_cast<YYSTYPE>(1);
1382 }
1383 else
1384 {
1385 (yyval) = (yyvsp[-3]) || (yyvsp[0]);
1386 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001387 }
Jamie Madill185de882014-12-22 15:17:52 -05001388
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001389 break;
1390
1391 case 7:
1392
1393 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001394 if ((yyvsp[-1]) == 0)
1395 {
1396 // Ignore errors in the short-circuited part of the expression.
1397 // ESSL3.00 section 3.4:
1398 // If an operand is not evaluated, the presence of undefined identifiers
1399 // in the operand will not cause an error.
1400 // Unevaluated division by zero should not cause an error either.
1401 context->startIgnoreErrors();
1402 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001403 }
Jamie Madill185de882014-12-22 15:17:52 -05001404
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001405 break;
1406
1407 case 8:
1408
1409 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001410 if ((yyvsp[-3]) == 0)
1411 {
1412 context->endIgnoreErrors();
1413 (yyval) = static_cast<YYSTYPE>(0);
1414 }
1415 else
1416 {
1417 (yyval) = (yyvsp[-3]) && (yyvsp[0]);
1418 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001419 }
Jamie Madill185de882014-12-22 15:17:52 -05001420
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001421 break;
1422
1423 case 9:
1424
1425 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001426 (yyval) = (yyvsp[-2]) | (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001427 }
Jamie Madill185de882014-12-22 15:17:52 -05001428
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001429 break;
1430
1431 case 10:
1432
1433 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001434 (yyval) = (yyvsp[-2]) ^ (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001435 }
Jamie Madill185de882014-12-22 15:17:52 -05001436
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001437 break;
1438
1439 case 11:
1440
1441 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001442 (yyval) = (yyvsp[-2]) & (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001443 }
Jamie Madill185de882014-12-22 15:17:52 -05001444
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001445 break;
1446
1447 case 12:
1448
1449 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001450 (yyval) = (yyvsp[-2]) != (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001451 }
Jamie Madill185de882014-12-22 15:17:52 -05001452
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001453 break;
1454
1455 case 13:
1456
1457 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001458 (yyval) = (yyvsp[-2]) == (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001459 }
Jamie Madill185de882014-12-22 15:17:52 -05001460
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001461 break;
1462
1463 case 14:
1464
1465 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001466 (yyval) = (yyvsp[-2]) >= (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001467 }
Jamie Madill185de882014-12-22 15:17:52 -05001468
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001469 break;
1470
1471 case 15:
1472
1473 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001474 (yyval) = (yyvsp[-2]) <= (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001475 }
Jamie Madill185de882014-12-22 15:17:52 -05001476
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001477 break;
1478
1479 case 16:
1480
1481 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001482 (yyval) = (yyvsp[-2]) > (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001483 }
Jamie Madill185de882014-12-22 15:17:52 -05001484
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001485 break;
1486
1487 case 17:
1488
1489 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001490 (yyval) = (yyvsp[-2]) < (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001491 }
Jamie Madill185de882014-12-22 15:17:52 -05001492
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001493 break;
1494
1495 case 18:
1496
1497 {
Geoff Langd4a07fb2016-09-20 10:24:23 -04001498 if ((yyvsp[-1]) < 0 || (yyvsp[0]) < 0)
Jamie Madill461e3af2016-07-21 18:15:34 -04001499 {
1500 if (!context->isIgnoringErrors())
1501 {
1502 std::ostringstream stream;
1503 stream << (yyvsp[-2]) << " >> " << (yyvsp[0]);
1504 std::string text = stream.str();
1505 context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
Geoff Lang93561c32016-09-20 10:22:55 -04001506 context->token->location,
1507 text.c_str());
Jamie Madill461e3af2016-07-21 18:15:34 -04001508 *(context->valid) = false;
1509 }
1510 (yyval) = static_cast<YYSTYPE>(0);
1511 }
1512 else
1513 {
1514 (yyval) = (yyvsp[-2]) >> (yyvsp[0]);
1515 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001516 }
Jamie Madill185de882014-12-22 15:17:52 -05001517
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001518 break;
1519
1520 case 19:
1521
1522 {
Geoff Langd4a07fb2016-09-20 10:24:23 -04001523 if ((yyvsp[-1]) < 0 || (yyvsp[0]) < 0)
Jamie Madill461e3af2016-07-21 18:15:34 -04001524 {
1525 if (!context->isIgnoringErrors())
1526 {
1527 std::ostringstream stream;
1528 stream << (yyvsp[-2]) << " << " << (yyvsp[0]);
1529 std::string text = stream.str();
1530 context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
Geoff Lang93561c32016-09-20 10:22:55 -04001531 context->token->location,
1532 text.c_str());
Jamie Madill461e3af2016-07-21 18:15:34 -04001533 *(context->valid) = false;
1534 }
1535 (yyval) = static_cast<YYSTYPE>(0);
1536 }
1537 else
1538 {
1539 (yyval) = (yyvsp[-2]) << (yyvsp[0]);
1540 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001541 }
Jamie Madill185de882014-12-22 15:17:52 -05001542
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001543 break;
1544
1545 case 20:
1546
1547 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001548 (yyval) = (yyvsp[-2]) - (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001549 }
Jamie Madill185de882014-12-22 15:17:52 -05001550
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001551 break;
1552
1553 case 21:
1554
1555 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001556 (yyval) = (yyvsp[-2]) + (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001557 }
Jamie Madill185de882014-12-22 15:17:52 -05001558
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001559 break;
1560
1561 case 22:
1562
1563 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001564 if ((yyvsp[0]) == 0)
1565 {
Olli Etuaho3187a382015-09-09 12:00:12 +03001566 if (!context->isIgnoringErrors())
Olli Etuaho809ec542015-08-26 14:30:57 +03001567 {
1568 std::ostringstream stream;
1569 stream << (yyvsp[-2]) << " % " << (yyvsp[0]);
1570 std::string text = stream.str();
1571 context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
1572 context->token->location,
1573 text.c_str());
Olli Etuaho247374c2015-09-09 15:07:24 +03001574 *(context->valid) = false;
Olli Etuaho809ec542015-08-26 14:30:57 +03001575 }
Olli Etuaho3187a382015-09-09 12:00:12 +03001576 (yyval) = static_cast<YYSTYPE>(0);
Olli Etuaho809ec542015-08-26 14:30:57 +03001577 }
1578 else
1579 {
1580 (yyval) = (yyvsp[-2]) % (yyvsp[0]);
1581 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001582 }
Jamie Madill185de882014-12-22 15:17:52 -05001583
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001584 break;
1585
1586 case 23:
1587
1588 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001589 if ((yyvsp[0]) == 0)
1590 {
Olli Etuaho3187a382015-09-09 12:00:12 +03001591 if (!context->isIgnoringErrors())
Olli Etuaho809ec542015-08-26 14:30:57 +03001592 {
1593 std::ostringstream stream;
1594 stream << (yyvsp[-2]) << " / " << (yyvsp[0]);
1595 std::string text = stream.str();
1596 context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
1597 context->token->location,
1598 text.c_str());
Olli Etuaho247374c2015-09-09 15:07:24 +03001599 *(context->valid) = false;
Olli Etuaho809ec542015-08-26 14:30:57 +03001600 }
Olli Etuaho3187a382015-09-09 12:00:12 +03001601 (yyval) = static_cast<YYSTYPE>(0);
Olli Etuaho809ec542015-08-26 14:30:57 +03001602 }
1603 else
1604 {
1605 (yyval) = (yyvsp[-2]) / (yyvsp[0]);
1606 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001607 }
Jamie Madill185de882014-12-22 15:17:52 -05001608
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001609 break;
1610
1611 case 24:
1612
1613 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001614 (yyval) = (yyvsp[-2]) * (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001615 }
Jamie Madill185de882014-12-22 15:17:52 -05001616
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001617 break;
1618
1619 case 25:
1620
1621 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001622 (yyval) = ! (yyvsp[0]);
Olli Etuaho6ffe6132015-08-26 14:30:57 +03001623 }
1624
1625 break;
1626
Jamie Madill9a1b49f2015-09-08 14:32:26 +00001627 case 26:
Olli Etuaho6ffe6132015-08-26 14:30:57 +03001628
1629 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001630 (yyval) = ~ (yyvsp[0]);
1631 }
1632
1633 break;
1634
1635 case 27:
1636
1637 {
1638 (yyval) = - (yyvsp[0]);
1639 }
1640
1641 break;
1642
1643 case 28:
1644
1645 {
1646 (yyval) = + (yyvsp[0]);
1647 }
1648
1649 break;
1650
1651 case 29:
1652
1653 {
Jamie Madill185de882014-12-22 15:17:52 -05001654 (yyval) = (yyvsp[-1]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001655 }
Jamie Madill185de882014-12-22 15:17:52 -05001656
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001657 break;
1658
1659
1660
1661 default: break;
1662 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001663 /* User semantic actions sometimes alter yychar, and that requires
1664 that yytoken be updated with the new translation. We take the
1665 approach of translating immediately before every use of yytoken.
1666 One alternative is translating here after every semantic action,
1667 but that translation would be missed if the semantic action invokes
1668 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1669 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1670 incorrect destructor might then be invoked immediately. In the
1671 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1672 to an incorrect destructor call or verbose syntax error message
1673 before the lookahead is translated. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001674 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1675
1676 YYPOPSTACK (yylen);
1677 yylen = 0;
1678 YY_STACK_PRINT (yyss, yyssp);
1679
1680 *++yyvsp = yyval;
1681
Jamie Madill185de882014-12-22 15:17:52 -05001682 /* Now 'shift' the result of the reduction. Determine what state
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001683 that goes to, based on the state we popped back to and the rule
1684 number reduced by. */
1685
1686 yyn = yyr1[yyn];
1687
1688 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1689 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1690 yystate = yytable[yystate];
1691 else
1692 yystate = yydefgoto[yyn - YYNTOKENS];
1693
1694 goto yynewstate;
1695
1696
Jamie Madill185de882014-12-22 15:17:52 -05001697/*--------------------------------------.
1698| yyerrlab -- here on detecting error. |
1699`--------------------------------------*/
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001700yyerrlab:
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001701 /* Make sure we have latest lookahead translation. See comments at
1702 user semantic actions for why this is necessary. */
1703 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1704
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001705 /* If not already recovering from an error, report this error. */
1706 if (!yyerrstatus)
1707 {
1708 ++yynerrs;
1709#if ! YYERROR_VERBOSE
1710 yyerror (context, YY_("syntax error"));
1711#else
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001712# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1713 yyssp, yytoken)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001714 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001715 char const *yymsgp = YY_("syntax error");
1716 int yysyntax_error_status;
1717 yysyntax_error_status = YYSYNTAX_ERROR;
1718 if (yysyntax_error_status == 0)
1719 yymsgp = yymsg;
1720 else if (yysyntax_error_status == 1)
1721 {
1722 if (yymsg != yymsgbuf)
1723 YYSTACK_FREE (yymsg);
1724 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1725 if (!yymsg)
1726 {
1727 yymsg = yymsgbuf;
1728 yymsg_alloc = sizeof yymsgbuf;
1729 yysyntax_error_status = 2;
1730 }
1731 else
1732 {
1733 yysyntax_error_status = YYSYNTAX_ERROR;
1734 yymsgp = yymsg;
1735 }
1736 }
1737 yyerror (context, yymsgp);
1738 if (yysyntax_error_status == 2)
1739 goto yyexhaustedlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001740 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001741# undef YYSYNTAX_ERROR
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001742#endif
1743 }
1744
1745
1746
1747 if (yyerrstatus == 3)
1748 {
1749 /* If just tried and failed to reuse lookahead token after an
Jamie Madill185de882014-12-22 15:17:52 -05001750 error, discard it. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001751
1752 if (yychar <= YYEOF)
Jamie Madill185de882014-12-22 15:17:52 -05001753 {
1754 /* Return failure if at end of input. */
1755 if (yychar == YYEOF)
1756 YYABORT;
1757 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001758 else
Jamie Madill185de882014-12-22 15:17:52 -05001759 {
1760 yydestruct ("Error: discarding",
1761 yytoken, &yylval, context);
1762 yychar = YYEMPTY;
1763 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001764 }
1765
1766 /* Else will try to reuse lookahead token after shifting the error
1767 token. */
1768 goto yyerrlab1;
1769
1770
1771/*---------------------------------------------------.
1772| yyerrorlab -- error raised explicitly by YYERROR. |
1773`---------------------------------------------------*/
1774yyerrorlab:
1775
1776 /* Pacify compilers like GCC when the user code never invokes
1777 YYERROR and the label yyerrorlab therefore never appears in user
1778 code. */
1779 if (/*CONSTCOND*/ 0)
1780 goto yyerrorlab;
1781
Jamie Madill185de882014-12-22 15:17:52 -05001782 /* Do not reclaim the symbols of the rule whose action triggered
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001783 this YYERROR. */
1784 YYPOPSTACK (yylen);
1785 yylen = 0;
1786 YY_STACK_PRINT (yyss, yyssp);
1787 yystate = *yyssp;
1788 goto yyerrlab1;
1789
1790
1791/*-------------------------------------------------------------.
1792| yyerrlab1 -- common code for both syntax error and YYERROR. |
1793`-------------------------------------------------------------*/
1794yyerrlab1:
Jamie Madill185de882014-12-22 15:17:52 -05001795 yyerrstatus = 3; /* Each real token shifted decrements this. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001796
1797 for (;;)
1798 {
1799 yyn = yypact[yystate];
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001800 if (!yypact_value_is_default (yyn))
Jamie Madill185de882014-12-22 15:17:52 -05001801 {
1802 yyn += YYTERROR;
1803 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1804 {
1805 yyn = yytable[yyn];
1806 if (0 < yyn)
1807 break;
1808 }
1809 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001810
1811 /* Pop the current state because it cannot handle the error token. */
1812 if (yyssp == yyss)
Jamie Madill185de882014-12-22 15:17:52 -05001813 YYABORT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001814
1815
1816 yydestruct ("Error: popping",
Jamie Madill185de882014-12-22 15:17:52 -05001817 yystos[yystate], yyvsp, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001818 YYPOPSTACK (1);
1819 yystate = *yyssp;
1820 YY_STACK_PRINT (yyss, yyssp);
1821 }
1822
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001823 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001824 *++yyvsp = yylval;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001825 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001826
1827
1828 /* Shift the error token. */
1829 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1830
1831 yystate = yyn;
1832 goto yynewstate;
1833
1834
1835/*-------------------------------------.
1836| yyacceptlab -- YYACCEPT comes here. |
1837`-------------------------------------*/
1838yyacceptlab:
1839 yyresult = 0;
1840 goto yyreturn;
1841
1842/*-----------------------------------.
1843| yyabortlab -- YYABORT comes here. |
1844`-----------------------------------*/
1845yyabortlab:
1846 yyresult = 1;
1847 goto yyreturn;
1848
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001849#if !defined yyoverflow || YYERROR_VERBOSE
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001850/*-------------------------------------------------.
1851| yyexhaustedlab -- memory exhaustion comes here. |
1852`-------------------------------------------------*/
1853yyexhaustedlab:
1854 yyerror (context, YY_("memory exhausted"));
1855 yyresult = 2;
1856 /* Fall through. */
1857#endif
1858
1859yyreturn:
1860 if (yychar != YYEMPTY)
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001861 {
1862 /* Make sure we have latest lookahead translation. See comments at
1863 user semantic actions for why this is necessary. */
1864 yytoken = YYTRANSLATE (yychar);
1865 yydestruct ("Cleanup: discarding lookahead",
1866 yytoken, &yylval, context);
1867 }
Jamie Madill185de882014-12-22 15:17:52 -05001868 /* Do not reclaim the symbols of the rule whose action triggered
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001869 this YYABORT or YYACCEPT. */
1870 YYPOPSTACK (yylen);
1871 YY_STACK_PRINT (yyss, yyssp);
1872 while (yyssp != yyss)
1873 {
1874 yydestruct ("Cleanup: popping",
Jamie Madill185de882014-12-22 15:17:52 -05001875 yystos[*yyssp], yyvsp, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001876 YYPOPSTACK (1);
1877 }
1878#ifndef yyoverflow
1879 if (yyss != yyssa)
1880 YYSTACK_FREE (yyss);
1881#endif
1882#if YYERROR_VERBOSE
1883 if (yymsg != yymsgbuf)
1884 YYSTACK_FREE (yymsg);
1885#endif
Jamie Madill185de882014-12-22 15:17:52 -05001886 return yyresult;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001887}
1888
1889
1890
Zhenyao Mod526f982014-05-13 14:51:19 -07001891int yylex(YYSTYPE *lvalp, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001892{
Olli Etuaho3187a382015-09-09 12:00:12 +03001893 pp::Token *token = context->token;
Olli Etuaho247374c2015-09-09 15:07:24 +03001894 if (!context->parsePresetToken)
1895 {
1896 context->lexer->lex(token);
1897 }
1898 context->parsePresetToken = false;
Olli Etuaho3187a382015-09-09 12:00:12 +03001899
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001900 int type = 0;
1901
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001902 switch (token->type)
1903 {
Zhenyao Mod526f982014-05-13 14:51:19 -07001904 case pp::Token::CONST_INT: {
alokp@chromium.org2e818912012-06-29 21:26:03 +00001905 unsigned int val = 0;
Olli Etuaho247374c2015-09-09 15:07:24 +03001906 int testVal = 0;
1907 if (!token->uValue(&val) || (!token->iValue(&testVal) &&
1908 context->errorSettings.integerLiteralsMustFit32BitSignedRange))
alokp@chromium.org2e818912012-06-29 21:26:03 +00001909 {
Shannon Woods7f2d7942013-11-19 15:07:58 -05001910 context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
alokp@chromium.org2e818912012-06-29 21:26:03 +00001911 token->location, token->text);
Olli Etuaho247374c2015-09-09 15:07:24 +03001912 *(context->valid) = false;
alokp@chromium.org2e818912012-06-29 21:26:03 +00001913 }
1914 *lvalp = static_cast<YYSTYPE>(val);
maxvujovic@gmail.come640ef82012-07-13 18:42:40 +00001915 type = TOK_CONST_INT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001916 break;
alokp@chromium.org2e818912012-06-29 21:26:03 +00001917 }
Olli Etuaho809ec542015-08-26 14:30:57 +03001918 case pp::Token::IDENTIFIER:
Olli Etuaho809ec542015-08-26 14:30:57 +03001919 *lvalp = static_cast<YYSTYPE>(-1);
1920 type = TOK_IDENTIFIER;
1921 break;
Zhenyao Mod526f982014-05-13 14:51:19 -07001922 case pp::Token::OP_OR:
1923 type = TOK_OP_OR;
1924 break;
1925 case pp::Token::OP_AND:
1926 type = TOK_OP_AND;
1927 break;
1928 case pp::Token::OP_NE:
1929 type = TOK_OP_NE;
1930 break;
1931 case pp::Token::OP_EQ:
1932 type = TOK_OP_EQ;
1933 break;
1934 case pp::Token::OP_GE:
1935 type = TOK_OP_GE;
1936 break;
1937 case pp::Token::OP_LE:
1938 type = TOK_OP_LE;
1939 break;
1940 case pp::Token::OP_RIGHT:
1941 type = TOK_OP_RIGHT;
1942 break;
1943 case pp::Token::OP_LEFT:
1944 type = TOK_OP_LEFT;
1945 break;
1946 case '|':
1947 case '^':
1948 case '&':
1949 case '>':
1950 case '<':
1951 case '-':
1952 case '+':
1953 case '%':
1954 case '/':
1955 case '*':
1956 case '!':
1957 case '~':
1958 case '(':
1959 case ')':
1960 type = token->type;
1961 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001962
Zhenyao Mod526f982014-05-13 14:51:19 -07001963 default:
1964 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001965 }
1966
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001967 return type;
1968}
1969
Zhenyao Mod526f982014-05-13 14:51:19 -07001970void yyerror(Context *context, const char *reason)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001971{
Shannon Woods7f2d7942013-11-19 15:07:58 -05001972 context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001973 context->token->location,
1974 reason);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001975}
1976
1977namespace pp {
1978
Zhenyao Mod526f982014-05-13 14:51:19 -07001979ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics)
1980 : mLexer(lexer),
1981 mDiagnostics(diagnostics)
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001982{
1983}
1984
Olli Etuaho247374c2015-09-09 15:07:24 +03001985bool ExpressionParser::parse(Token *token,
1986 int *result,
1987 bool parsePresetToken,
1988 const ErrorSettings &errorSettings,
1989 bool *valid)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001990{
1991 Context context;
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001992 context.diagnostics = mDiagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001993 context.lexer = mLexer;
1994 context.token = token;
1995 context.result = result;
Olli Etuaho809ec542015-08-26 14:30:57 +03001996 context.ignoreErrors = 0;
Olli Etuaho247374c2015-09-09 15:07:24 +03001997 context.parsePresetToken = parsePresetToken;
1998 context.errorSettings = errorSettings;
1999 context.valid = valid;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002000 int ret = yyparse(&context);
2001 switch (ret)
2002 {
2003 case 0:
2004 case 1:
2005 break;
2006
2007 case 2:
Shannon Woods7f2d7942013-11-19 15:07:58 -05002008 mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002009 break;
2010
2011 default:
2012 assert(false);
Shannon Woods7f2d7942013-11-19 15:07:58 -05002013 mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002014 break;
2015 }
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00002016
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002017 return ret == 0;
2018}
2019
2020} // namespace pp