blob: fb455633ce53e13e972503a40be4b7be62aa9277 [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. */
Jamie Madill461e3af2016-07-21 18:15:34 -0400501static const yytype_uint16 yyrline[] = {0, 110, 110, 117, 118, 129, 129, 150, 150, 171,
502 174, 177, 180, 183, 186, 189, 192, 195, 198, 218,
503 238, 241, 244, 264, 284, 287, 290, 293, 296, 299};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000504#endif
505
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000506#if YYDEBUG || YYERROR_VERBOSE || 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000507/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
508 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
509static const char *const yytname[] =
510{
Olli Etuaho809ec542015-08-26 14:30:57 +0300511 "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_IDENTIFIER",
512 "TOK_OP_OR", "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_EQ", "TOK_OP_NE",
513 "'<'", "'>'", "TOK_OP_LE", "TOK_OP_GE", "TOK_OP_LEFT", "TOK_OP_RIGHT",
514 "'+'", "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('",
515 "')'", "$accept", "input", "expression", "$@1", "$@2", YY_NULLPTR
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000516};
517#endif
518
519# ifdef YYPRINT
Jamie Madill185de882014-12-22 15:17:52 -0500520/* YYTOKNUM[NUM] -- (External) token number corresponding to the
521 (internal) symbol number NUM (which must be that of a token). */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000522static const yytype_uint16 yytoknum[] =
523{
Olli Etuaho809ec542015-08-26 14:30:57 +0300524 0, 256, 257, 258, 259, 260, 261, 124, 94, 38,
525 262, 263, 60, 62, 264, 265, 266, 267, 43, 45,
526 42, 47, 37, 268, 33, 126, 40, 41
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000527};
528# endif
529
Olli Etuaho809ec542015-08-26 14:30:57 +0300530#define YYPACT_NINF -12
Jamie Madill185de882014-12-22 15:17:52 -0500531
532#define yypact_value_is_default(Yystate) \
Olli Etuaho809ec542015-08-26 14:30:57 +0300533 (!!((Yystate) == (-12)))
Jamie Madill185de882014-12-22 15:17:52 -0500534
535#define YYTABLE_NINF -1
536
537#define yytable_value_is_error(Yytable_value) \
538 0
539
540 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
541 STATE-NUM. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000542static const yytype_int16 yypact[] =
543{
Olli Etuaho809ec542015-08-26 14:30:57 +0300544 31, -12, -12, 31, 31, 31, 31, 31, 51, 76,
545 -12, -12, -12, -12, 53, -12, -12, -12, 31, 31,
546 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
547 31, 31, 31, 31, -12, 31, 31, 124, 138, 26,
548 149, 149, -11, -11, -11, -11, 154, 154, -8, -8,
549 -12, -12, -12, 93, 109
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000550};
551
Jamie Madill185de882014-12-22 15:17:52 -0500552 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
553 Performed when YYTABLE does not specify something else to do. Zero
554 means the default is an error. */
555static const yytype_uint8 yydefact[] =
556{
Olli Etuaho809ec542015-08-26 14:30:57 +0300557 0, 3, 4, 0, 0, 0, 0, 0, 0, 2,
558 28, 27, 25, 26, 0, 1, 5, 7, 0, 0,
Jamie Madill185de882014-12-22 15:17:52 -0500559 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Olli Etuaho809ec542015-08-26 14:30:57 +0300560 0, 0, 0, 0, 29, 0, 0, 9, 10, 11,
561 13, 12, 17, 16, 15, 14, 19, 18, 21, 20,
562 24, 23, 22, 6, 8
Jamie Madill185de882014-12-22 15:17:52 -0500563};
564
565 /* YYPGOTO[NTERM-NUM]. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000566static const yytype_int8 yypgoto[] =
567{
Olli Etuaho809ec542015-08-26 14:30:57 +0300568 -12, -12, -3, -12, -12
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000569};
570
Jamie Madill185de882014-12-22 15:17:52 -0500571 /* YYDEFGOTO[NTERM-NUM]. */
572static const yytype_int8 yydefgoto[] =
573{
Olli Etuaho809ec542015-08-26 14:30:57 +0300574 -1, 8, 9, 35, 36
Jamie Madill185de882014-12-22 15:17:52 -0500575};
576
577 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
578 positive, shift that token. If negative, reduce the rule whose
579 number is the opposite. If YYTABLE_NINF, syntax error. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000580static const yytype_uint8 yytable[] =
581{
Olli Etuaho809ec542015-08-26 14:30:57 +0300582 10, 11, 12, 13, 14, 27, 28, 29, 30, 31,
583 32, 33, 31, 32, 33, 37, 38, 39, 40, 41,
584 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
585 52, 0, 53, 54, 1, 2, 21, 22, 23, 24,
586 25, 26, 27, 28, 29, 30, 31, 32, 33, 3,
587 4, 15, 0, 0, 0, 5, 6, 7, 16, 17,
588 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
589 28, 29, 30, 31, 32, 33, 0, 0, 0, 0,
590 34, 16, 17, 18, 19, 20, 21, 22, 23, 24,
591 25, 26, 27, 28, 29, 30, 31, 32, 33, 17,
592 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
593 28, 29, 30, 31, 32, 33, 18, 19, 20, 21,
594 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
595 32, 33, 19, 20, 21, 22, 23, 24, 25, 26,
596 27, 28, 29, 30, 31, 32, 33, 20, 21, 22,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000597 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
Olli Etuaho809ec542015-08-26 14:30:57 +0300598 33, 23, 24, 25, 26, 27, 28, 29, 30, 31,
599 32, 33, 29, 30, 31, 32, 33
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000600};
601
602static const yytype_int8 yycheck[] =
603{
Olli Etuaho809ec542015-08-26 14:30:57 +0300604 3, 4, 5, 6, 7, 16, 17, 18, 19, 20,
605 21, 22, 20, 21, 22, 18, 19, 20, 21, 22,
606 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
607 33, -1, 35, 36, 3, 4, 10, 11, 12, 13,
608 14, 15, 16, 17, 18, 19, 20, 21, 22, 18,
609 19, 0, -1, -1, -1, 24, 25, 26, 5, 6,
610 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
611 17, 18, 19, 20, 21, 22, -1, -1, -1, -1,
612 27, 5, 6, 7, 8, 9, 10, 11, 12, 13,
613 14, 15, 16, 17, 18, 19, 20, 21, 22, 6,
614 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
615 17, 18, 19, 20, 21, 22, 7, 8, 9, 10,
616 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
617 21, 22, 8, 9, 10, 11, 12, 13, 14, 15,
618 16, 17, 18, 19, 20, 21, 22, 9, 10, 11,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000619 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Olli Etuaho809ec542015-08-26 14:30:57 +0300620 22, 12, 13, 14, 15, 16, 17, 18, 19, 20,
621 21, 22, 18, 19, 20, 21, 22
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000622};
623
Jamie Madill185de882014-12-22 15:17:52 -0500624 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
625 symbol of state STATE-NUM. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000626static const yytype_uint8 yystos[] =
627{
Olli Etuaho809ec542015-08-26 14:30:57 +0300628 0, 3, 4, 18, 19, 24, 25, 26, 29, 30,
629 30, 30, 30, 30, 30, 0, 5, 6, 7, 8,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000630 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Olli Etuaho809ec542015-08-26 14:30:57 +0300631 19, 20, 21, 22, 27, 31, 32, 30, 30, 30,
632 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
633 30, 30, 30, 30, 30
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000634};
635
Jamie Madill185de882014-12-22 15:17:52 -0500636 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
637static const yytype_uint8 yyr1[] =
638{
Olli Etuaho809ec542015-08-26 14:30:57 +0300639 0, 28, 29, 30, 30, 31, 30, 32, 30, 30,
640 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
641 30, 30, 30, 30, 30, 30, 30, 30, 30, 30
Jamie Madill185de882014-12-22 15:17:52 -0500642};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000643
Jamie Madill185de882014-12-22 15:17:52 -0500644 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
645static const yytype_uint8 yyr2[] =
646{
Olli Etuaho809ec542015-08-26 14:30:57 +0300647 0, 2, 1, 1, 1, 0, 4, 0, 4, 3,
Jamie Madill185de882014-12-22 15:17:52 -0500648 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Olli Etuaho809ec542015-08-26 14:30:57 +0300649 3, 3, 3, 3, 3, 2, 2, 2, 2, 3
Jamie Madill185de882014-12-22 15:17:52 -0500650};
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000651
652
Jamie Madill185de882014-12-22 15:17:52 -0500653#define yyerrok (yyerrstatus = 0)
654#define yyclearin (yychar = YYEMPTY)
655#define YYEMPTY (-2)
656#define YYEOF 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000657
Jamie Madill185de882014-12-22 15:17:52 -0500658#define YYACCEPT goto yyacceptlab
659#define YYABORT goto yyabortlab
660#define YYERROR goto yyerrorlab
661
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000662
663#define YYRECOVERING() (!!yyerrstatus)
664
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000665#define YYBACKUP(Token, Value) \
666do \
667 if (yychar == YYEMPTY) \
668 { \
669 yychar = (Token); \
670 yylval = (Value); \
671 YYPOPSTACK (yylen); \
672 yystate = *yyssp; \
673 goto yybackup; \
674 } \
675 else \
676 { \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000677 yyerror (context, YY_("syntax error: cannot back up")); \
Jamie Madill185de882014-12-22 15:17:52 -0500678 YYERROR; \
679 } \
680while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000681
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000682/* Error token number */
Jamie Madill185de882014-12-22 15:17:52 -0500683#define YYTERROR 1
684#define YYERRCODE 256
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000685
686
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000687
688/* Enable debugging if requested. */
689#if YYDEBUG
690
691# ifndef YYFPRINTF
692# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
693# define YYFPRINTF fprintf
694# endif
695
Jamie Madill185de882014-12-22 15:17:52 -0500696# define YYDPRINTF(Args) \
697do { \
698 if (yydebug) \
699 YYFPRINTF Args; \
700} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000701
Jamie Madill185de882014-12-22 15:17:52 -0500702/* This macro is provided for backward compatibility. */
703#ifndef YY_LOCATION_PRINT
704# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
705#endif
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000706
707
Jamie Madill185de882014-12-22 15:17:52 -0500708# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
709do { \
710 if (yydebug) \
711 { \
712 YYFPRINTF (stderr, "%s ", Title); \
713 yy_symbol_print (stderr, \
714 Type, Value, context); \
715 YYFPRINTF (stderr, "\n"); \
716 } \
717} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000718
Jamie Madill185de882014-12-22 15:17:52 -0500719
720/*----------------------------------------.
721| Print this symbol's value on YYOUTPUT. |
722`----------------------------------------*/
723
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000724static void
725yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000726{
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000727 FILE *yyo = yyoutput;
728 YYUSE (yyo);
Jamie Madill185de882014-12-22 15:17:52 -0500729 YYUSE (context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000730 if (!yyvaluep)
731 return;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000732# ifdef YYPRINT
733 if (yytype < YYNTOKENS)
734 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000735# endif
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400736 YYUSE (yytype);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000737}
738
739
740/*--------------------------------.
741| Print this symbol on YYOUTPUT. |
742`--------------------------------*/
743
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000744static void
745yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000746{
Jamie Madill185de882014-12-22 15:17:52 -0500747 YYFPRINTF (yyoutput, "%s %s (",
748 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000749
750 yy_symbol_value_print (yyoutput, yytype, yyvaluep, context);
751 YYFPRINTF (yyoutput, ")");
752}
753
754/*------------------------------------------------------------------.
755| yy_stack_print -- Print the state stack from its BOTTOM up to its |
756| TOP (included). |
757`------------------------------------------------------------------*/
758
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000759static void
760yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000761{
762 YYFPRINTF (stderr, "Stack now");
763 for (; yybottom <= yytop; yybottom++)
764 {
765 int yybot = *yybottom;
766 YYFPRINTF (stderr, " %d", yybot);
767 }
768 YYFPRINTF (stderr, "\n");
769}
770
Jamie Madill185de882014-12-22 15:17:52 -0500771# define YY_STACK_PRINT(Bottom, Top) \
772do { \
773 if (yydebug) \
774 yy_stack_print ((Bottom), (Top)); \
775} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000776
777
778/*------------------------------------------------.
779| Report that the YYRULE is going to be reduced. |
780`------------------------------------------------*/
781
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000782static void
Jamie Madill185de882014-12-22 15:17:52 -0500783yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000784{
Jamie Madill185de882014-12-22 15:17:52 -0500785 unsigned long int yylno = yyrline[yyrule];
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000786 int yynrhs = yyr2[yyrule];
787 int yyi;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000788 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
Jamie Madill185de882014-12-22 15:17:52 -0500789 yyrule - 1, yylno);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000790 /* The symbols being reduced. */
791 for (yyi = 0; yyi < yynrhs; yyi++)
792 {
793 YYFPRINTF (stderr, " $%d = ", yyi + 1);
Jamie Madill185de882014-12-22 15:17:52 -0500794 yy_symbol_print (stderr,
795 yystos[yyssp[yyi + 1 - yynrhs]],
796 &(yyvsp[(yyi + 1) - (yynrhs)])
797 , context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000798 YYFPRINTF (stderr, "\n");
799 }
800}
801
Jamie Madill185de882014-12-22 15:17:52 -0500802# define YY_REDUCE_PRINT(Rule) \
803do { \
804 if (yydebug) \
805 yy_reduce_print (yyssp, yyvsp, Rule, context); \
806} while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000807
808/* Nonzero means print parse trace. It is left uninitialized so that
809 multiple parsers can coexist. */
810int yydebug;
811#else /* !YYDEBUG */
812# define YYDPRINTF(Args)
813# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
814# define YY_STACK_PRINT(Bottom, Top)
815# define YY_REDUCE_PRINT(Rule)
816#endif /* !YYDEBUG */
817
818
819/* YYINITDEPTH -- initial size of the parser's stacks. */
Jamie Madill185de882014-12-22 15:17:52 -0500820#ifndef YYINITDEPTH
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000821# define YYINITDEPTH 200
822#endif
823
824/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
825 if the built-in stack extension method is used).
826
827 Do not make this value too large; the results are undefined if
828 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
829 evaluated with infinite-precision integer arithmetic. */
830
831#ifndef YYMAXDEPTH
832# define YYMAXDEPTH 10000
833#endif
834
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000835
836#if YYERROR_VERBOSE
837
838# ifndef yystrlen
839# if defined __GLIBC__ && defined _STRING_H
840# define yystrlen strlen
841# else
842/* Return the length of YYSTR. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000843static YYSIZE_T
844yystrlen (const char *yystr)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000845{
846 YYSIZE_T yylen;
847 for (yylen = 0; yystr[yylen]; yylen++)
848 continue;
849 return yylen;
850}
851# endif
852# endif
853
854# ifndef yystpcpy
855# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
856# define yystpcpy stpcpy
857# else
858/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
859 YYDEST. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000860static char *
861yystpcpy (char *yydest, const char *yysrc)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000862{
863 char *yyd = yydest;
864 const char *yys = yysrc;
865
866 while ((*yyd++ = *yys++) != '\0')
867 continue;
868
869 return yyd - 1;
870}
871# endif
872# endif
873
874# ifndef yytnamerr
875/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
876 quotes and backslashes, so that it's suitable for yyerror. The
877 heuristic is that double-quoting is unnecessary unless the string
878 contains an apostrophe, a comma, or backslash (other than
879 backslash-backslash). YYSTR is taken from yytname. If YYRES is
880 null, do not copy; instead, return the length of what the result
881 would have been. */
882static YYSIZE_T
883yytnamerr (char *yyres, const char *yystr)
884{
885 if (*yystr == '"')
886 {
887 YYSIZE_T yyn = 0;
888 char const *yyp = yystr;
889
890 for (;;)
Jamie Madill185de882014-12-22 15:17:52 -0500891 switch (*++yyp)
892 {
893 case '\'':
894 case ',':
895 goto do_not_strip_quotes;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000896
Jamie Madill185de882014-12-22 15:17:52 -0500897 case '\\':
898 if (*++yyp != '\\')
899 goto do_not_strip_quotes;
900 /* Fall through. */
901 default:
902 if (yyres)
903 yyres[yyn] = *yyp;
904 yyn++;
905 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000906
Jamie Madill185de882014-12-22 15:17:52 -0500907 case '"':
908 if (yyres)
909 yyres[yyn] = '\0';
910 return yyn;
911 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000912 do_not_strip_quotes: ;
913 }
914
915 if (! yyres)
916 return yystrlen (yystr);
917
918 return yystpcpy (yyres, yystr) - yyres;
919}
920# endif
921
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000922/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
923 about the unexpected token YYTOKEN for the state stack whose top is
924 YYSSP.
925
926 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
927 not large enough to hold the message. In that case, also set
928 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
929 required number of bytes is too large to store. */
930static int
931yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
932 yytype_int16 *yyssp, int yytoken)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000933{
Jamie Madill185de882014-12-22 15:17:52 -0500934 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000935 YYSIZE_T yysize = yysize0;
936 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
937 /* Internationalized format string. */
Jamie Madill185de882014-12-22 15:17:52 -0500938 const char *yyformat = YY_NULLPTR;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000939 /* Arguments of yyformat. */
940 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
941 /* Number of reported tokens (one for the "unexpected", one per
942 "expected"). */
943 int yycount = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000944
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000945 /* There are many possibilities here to consider:
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000946 - If this state is a consistent state with a default action, then
947 the only way this function was invoked is if the default action
948 is an error action. In that case, don't check for expected
949 tokens because there are none.
950 - The only way there can be no lookahead present (in yychar) is if
951 this state is a consistent state with a default action. Thus,
952 detecting the absence of a lookahead is sufficient to determine
953 that there is no unexpected or expected token to report. In that
954 case, just report a simple "syntax error".
955 - Don't assume there isn't a lookahead just because this state is a
956 consistent state with a default action. There might have been a
957 previous inconsistent state, consistent state with a non-default
958 action, or user semantic action that manipulated yychar.
959 - Of course, the expected token list depends on states to have
960 correct lookahead information, and it depends on the parser not
961 to perform extra reductions after fetching a lookahead from the
962 scanner and before detecting a syntax error. Thus, state merging
963 (from LALR or IELR) and default reductions corrupt the expected
964 token list. However, the list is correct for canonical LR with
965 one exception: it will still contain any token that will not be
966 accepted due to an error action in a later state.
967 */
968 if (yytoken != YYEMPTY)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000969 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000970 int yyn = yypact[*yyssp];
971 yyarg[yycount++] = yytname[yytoken];
972 if (!yypact_value_is_default (yyn))
973 {
974 /* Start YYX at -YYN if negative to avoid negative indexes in
975 YYCHECK. In other words, skip the first -YYN actions for
976 this state because they are default actions. */
977 int yyxbegin = yyn < 0 ? -yyn : 0;
978 /* Stay within bounds of both yycheck and yytname. */
979 int yychecklim = YYLAST - yyn + 1;
980 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
981 int yyx;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000982
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000983 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
984 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
985 && !yytable_value_is_error (yytable[yyx + yyn]))
986 {
987 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
988 {
989 yycount = 1;
990 yysize = yysize0;
991 break;
992 }
993 yyarg[yycount++] = yytname[yyx];
994 {
Jamie Madill185de882014-12-22 15:17:52 -0500995 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000996 if (! (yysize <= yysize1
997 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
998 return 2;
999 yysize = yysize1;
1000 }
1001 }
1002 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001003 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001004
1005 switch (yycount)
1006 {
1007# define YYCASE_(N, S) \
1008 case N: \
1009 yyformat = S; \
1010 break
1011 YYCASE_(0, YY_("syntax error"));
1012 YYCASE_(1, YY_("syntax error, unexpected %s"));
1013 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1014 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1015 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1016 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1017# undef YYCASE_
1018 }
1019
1020 {
1021 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1022 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1023 return 2;
1024 yysize = yysize1;
1025 }
1026
1027 if (*yymsg_alloc < yysize)
1028 {
1029 *yymsg_alloc = 2 * yysize;
1030 if (! (yysize <= *yymsg_alloc
1031 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1032 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1033 return 1;
1034 }
1035
1036 /* Avoid sprintf, as that infringes on the user's name space.
1037 Don't have undefined behavior even if the translation
1038 produced a string with the wrong number of "%s"s. */
1039 {
1040 char *yyp = *yymsg;
1041 int yyi = 0;
1042 while ((*yyp = *yyformat) != '\0')
1043 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1044 {
1045 yyp += yytnamerr (yyp, yyarg[yyi++]);
1046 yyformat += 2;
1047 }
1048 else
1049 {
1050 yyp++;
1051 yyformat++;
1052 }
1053 }
1054 return 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001055}
1056#endif /* YYERROR_VERBOSE */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001057
1058/*-----------------------------------------------.
1059| Release the memory associated to this symbol. |
1060`-----------------------------------------------*/
1061
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001062static void
1063yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001064{
1065 YYUSE (yyvaluep);
1066 YYUSE (context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001067 if (!yymsg)
1068 yymsg = "Deleting";
1069 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1070
Jamie Madill185de882014-12-22 15:17:52 -05001071 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001072 YYUSE (yytype);
Jamie Madill185de882014-12-22 15:17:52 -05001073 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001074}
1075
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001076
1077
1078
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001079/*----------.
1080| yyparse. |
1081`----------*/
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001082
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001083int
1084yyparse (Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001085{
1086/* The lookahead symbol. */
1087int yychar;
1088
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001089
Jamie Madill185de882014-12-22 15:17:52 -05001090/* The semantic value of the lookahead symbol. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001091/* Default value used for initialization, for pacifying older GCCs
1092 or non-GCC compilers. */
Jamie Madill185de882014-12-22 15:17:52 -05001093YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1094YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001095
1096 /* Number of syntax errors so far. */
1097 int yynerrs;
1098
1099 int yystate;
1100 /* Number of tokens to shift before error messages enabled. */
1101 int yyerrstatus;
1102
1103 /* The stacks and their tools:
Jamie Madill185de882014-12-22 15:17:52 -05001104 'yyss': related to states.
1105 'yyvs': related to semantic values.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001106
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001107 Refer to the stacks through separate pointers, to allow yyoverflow
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001108 to reallocate them elsewhere. */
1109
1110 /* The state stack. */
1111 yytype_int16 yyssa[YYINITDEPTH];
1112 yytype_int16 *yyss;
1113 yytype_int16 *yyssp;
1114
1115 /* The semantic value stack. */
1116 YYSTYPE yyvsa[YYINITDEPTH];
1117 YYSTYPE *yyvs;
1118 YYSTYPE *yyvsp;
1119
1120 YYSIZE_T yystacksize;
1121
1122 int yyn;
1123 int yyresult;
1124 /* Lookahead token as an internal (translated) token number. */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001125 int yytoken = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001126 /* The variables used to return semantic value and location from the
1127 action routines. */
1128 YYSTYPE yyval;
1129
1130#if YYERROR_VERBOSE
1131 /* Buffer for error messages, and its allocated size. */
1132 char yymsgbuf[128];
1133 char *yymsg = yymsgbuf;
1134 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1135#endif
1136
1137#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1138
1139 /* The number of symbols on the RHS of the reduced rule.
1140 Keep to zero when no symbol should be popped. */
1141 int yylen = 0;
1142
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001143 yyssp = yyss = yyssa;
1144 yyvsp = yyvs = yyvsa;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001145 yystacksize = YYINITDEPTH;
1146
1147 YYDPRINTF ((stderr, "Starting parse\n"));
1148
1149 yystate = 0;
1150 yyerrstatus = 0;
1151 yynerrs = 0;
1152 yychar = YYEMPTY; /* Cause a token to be read. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001153 goto yysetstate;
1154
1155/*------------------------------------------------------------.
1156| yynewstate -- Push a new state, which is found in yystate. |
1157`------------------------------------------------------------*/
1158 yynewstate:
1159 /* In all cases, when you get here, the value and location stacks
1160 have just been pushed. So pushing a state here evens the stacks. */
1161 yyssp++;
1162
1163 yysetstate:
1164 *yyssp = yystate;
1165
1166 if (yyss + yystacksize - 1 <= yyssp)
1167 {
1168 /* Get the current used size of the three stacks, in elements. */
1169 YYSIZE_T yysize = yyssp - yyss + 1;
1170
1171#ifdef yyoverflow
1172 {
Jamie Madill185de882014-12-22 15:17:52 -05001173 /* Give user a chance to reallocate the stack. Use copies of
1174 these so that the &'s don't force the real ones into
1175 memory. */
1176 YYSTYPE *yyvs1 = yyvs;
1177 yytype_int16 *yyss1 = yyss;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001178
Jamie Madill185de882014-12-22 15:17:52 -05001179 /* Each stack pointer address is followed by the size of the
1180 data in use in that stack, in bytes. This used to be a
1181 conditional around just the two extra args, but that might
1182 be undefined if yyoverflow is a macro. */
1183 yyoverflow (YY_("memory exhausted"),
1184 &yyss1, yysize * sizeof (*yyssp),
1185 &yyvs1, yysize * sizeof (*yyvsp),
1186 &yystacksize);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001187
Jamie Madill185de882014-12-22 15:17:52 -05001188 yyss = yyss1;
1189 yyvs = yyvs1;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001190 }
1191#else /* no yyoverflow */
1192# ifndef YYSTACK_RELOCATE
1193 goto yyexhaustedlab;
1194# else
1195 /* Extend the stack our own way. */
1196 if (YYMAXDEPTH <= yystacksize)
Jamie Madill185de882014-12-22 15:17:52 -05001197 goto yyexhaustedlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001198 yystacksize *= 2;
1199 if (YYMAXDEPTH < yystacksize)
Jamie Madill185de882014-12-22 15:17:52 -05001200 yystacksize = YYMAXDEPTH;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001201
1202 {
Jamie Madill185de882014-12-22 15:17:52 -05001203 yytype_int16 *yyss1 = yyss;
1204 union yyalloc *yyptr =
1205 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1206 if (! yyptr)
1207 goto yyexhaustedlab;
1208 YYSTACK_RELOCATE (yyss_alloc, yyss);
1209 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001210# undef YYSTACK_RELOCATE
Jamie Madill185de882014-12-22 15:17:52 -05001211 if (yyss1 != yyssa)
1212 YYSTACK_FREE (yyss1);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001213 }
1214# endif
1215#endif /* no yyoverflow */
1216
1217 yyssp = yyss + yysize - 1;
1218 yyvsp = yyvs + yysize - 1;
1219
1220 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
Jamie Madill185de882014-12-22 15:17:52 -05001221 (unsigned long int) yystacksize));
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001222
1223 if (yyss + yystacksize - 1 <= yyssp)
Jamie Madill185de882014-12-22 15:17:52 -05001224 YYABORT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001225 }
1226
1227 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1228
1229 if (yystate == YYFINAL)
1230 YYACCEPT;
1231
1232 goto yybackup;
1233
1234/*-----------.
1235| yybackup. |
1236`-----------*/
1237yybackup:
1238
1239 /* Do appropriate processing given the current state. Read a
1240 lookahead token if we need one and don't already have one. */
1241
1242 /* First try to decide what to do without reference to lookahead token. */
1243 yyn = yypact[yystate];
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001244 if (yypact_value_is_default (yyn))
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001245 goto yydefault;
1246
1247 /* Not known => get a lookahead token if don't already have one. */
1248
1249 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1250 if (yychar == YYEMPTY)
1251 {
1252 YYDPRINTF ((stderr, "Reading a token: "));
Jamie Madill185de882014-12-22 15:17:52 -05001253 yychar = yylex (&yylval, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001254 }
1255
1256 if (yychar <= YYEOF)
1257 {
1258 yychar = yytoken = YYEOF;
1259 YYDPRINTF ((stderr, "Now at end of input.\n"));
1260 }
1261 else
1262 {
1263 yytoken = YYTRANSLATE (yychar);
1264 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1265 }
1266
1267 /* If the proper action on seeing token YYTOKEN is to reduce or to
1268 detect an error, take that action. */
1269 yyn += yytoken;
1270 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1271 goto yydefault;
1272 yyn = yytable[yyn];
1273 if (yyn <= 0)
1274 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001275 if (yytable_value_is_error (yyn))
1276 goto yyerrlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001277 yyn = -yyn;
1278 goto yyreduce;
1279 }
1280
1281 /* Count tokens shifted since error; after three, turn off error
1282 status. */
1283 if (yyerrstatus)
1284 yyerrstatus--;
1285
1286 /* Shift the lookahead token. */
1287 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1288
1289 /* Discard the shifted token. */
1290 yychar = YYEMPTY;
1291
1292 yystate = yyn;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001293 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001294 *++yyvsp = yylval;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001295 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001296
1297 goto yynewstate;
1298
1299
1300/*-----------------------------------------------------------.
1301| yydefault -- do the default action for the current state. |
1302`-----------------------------------------------------------*/
1303yydefault:
1304 yyn = yydefact[yystate];
1305 if (yyn == 0)
1306 goto yyerrlab;
1307 goto yyreduce;
1308
1309
1310/*-----------------------------.
1311| yyreduce -- Do a reduction. |
1312`-----------------------------*/
1313yyreduce:
1314 /* yyn is the number of a rule to reduce with. */
1315 yylen = yyr2[yyn];
1316
1317 /* If YYLEN is nonzero, implement the default value of the action:
Jamie Madill185de882014-12-22 15:17:52 -05001318 '$$ = $1'.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001319
1320 Otherwise, the following line sets YYVAL to garbage.
1321 This behavior is undocumented and Bison
1322 users should not rely upon it. Assigning to YYVAL
1323 unconditionally makes the parser a bit smaller, and it avoids a
1324 GCC warning that YYVAL may be used uninitialized. */
1325 yyval = yyvsp[1-yylen];
1326
1327
1328 YY_REDUCE_PRINT (yyn);
1329 switch (yyn)
1330 {
1331 case 2:
1332
1333 {
Jamie Madill185de882014-12-22 15:17:52 -05001334 *(context->result) = static_cast<int>((yyvsp[0]));
Olli Etuaho3187a382015-09-09 12:00:12 +03001335 YYACCEPT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001336 }
Jamie Madill185de882014-12-22 15:17:52 -05001337
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001338 break;
1339
1340 case 4:
1341
1342 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001343 if (!context->isIgnoringErrors())
1344 {
Olli Etuaho3187a382015-09-09 12:00:12 +03001345 // This rule should be applied right after the token is lexed, so we can
1346 // refer to context->token in the error message.
Olli Etuaho247374c2015-09-09 15:07:24 +03001347 context->diagnostics->report(context->errorSettings.unexpectedIdentifier,
Olli Etuaho3187a382015-09-09 12:00:12 +03001348 context->token->location, context->token->text);
Olli Etuaho247374c2015-09-09 15:07:24 +03001349 *(context->valid) = false;
Olli Etuaho809ec542015-08-26 14:30:57 +03001350 }
Olli Etuaho3187a382015-09-09 12:00:12 +03001351 (yyval) = (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001352 }
Jamie Madill185de882014-12-22 15:17:52 -05001353
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001354 break;
1355
1356 case 5:
1357
1358 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001359 if ((yyvsp[-1]) != 0)
1360 {
1361 // Ignore errors in the short-circuited part of the expression.
1362 // ESSL3.00 section 3.4:
1363 // If an operand is not evaluated, the presence of undefined identifiers
1364 // in the operand will not cause an error.
1365 // Unevaluated division by zero should not cause an error either.
1366 context->startIgnoreErrors();
1367 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001368 }
Jamie Madill185de882014-12-22 15:17:52 -05001369
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001370 break;
1371
1372 case 6:
1373
1374 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001375 if ((yyvsp[-3]) != 0)
1376 {
1377 context->endIgnoreErrors();
1378 (yyval) = static_cast<YYSTYPE>(1);
1379 }
1380 else
1381 {
1382 (yyval) = (yyvsp[-3]) || (yyvsp[0]);
1383 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001384 }
Jamie Madill185de882014-12-22 15:17:52 -05001385
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001386 break;
1387
1388 case 7:
1389
1390 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001391 if ((yyvsp[-1]) == 0)
1392 {
1393 // Ignore errors in the short-circuited part of the expression.
1394 // ESSL3.00 section 3.4:
1395 // If an operand is not evaluated, the presence of undefined identifiers
1396 // in the operand will not cause an error.
1397 // Unevaluated division by zero should not cause an error either.
1398 context->startIgnoreErrors();
1399 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001400 }
Jamie Madill185de882014-12-22 15:17:52 -05001401
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001402 break;
1403
1404 case 8:
1405
1406 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001407 if ((yyvsp[-3]) == 0)
1408 {
1409 context->endIgnoreErrors();
1410 (yyval) = static_cast<YYSTYPE>(0);
1411 }
1412 else
1413 {
1414 (yyval) = (yyvsp[-3]) && (yyvsp[0]);
1415 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001416 }
Jamie Madill185de882014-12-22 15:17:52 -05001417
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001418 break;
1419
1420 case 9:
1421
1422 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001423 (yyval) = (yyvsp[-2]) | (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001424 }
Jamie Madill185de882014-12-22 15:17:52 -05001425
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001426 break;
1427
1428 case 10:
1429
1430 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001431 (yyval) = (yyvsp[-2]) ^ (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001432 }
Jamie Madill185de882014-12-22 15:17:52 -05001433
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001434 break;
1435
1436 case 11:
1437
1438 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001439 (yyval) = (yyvsp[-2]) & (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001440 }
Jamie Madill185de882014-12-22 15:17:52 -05001441
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001442 break;
1443
1444 case 12:
1445
1446 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001447 (yyval) = (yyvsp[-2]) != (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001448 }
Jamie Madill185de882014-12-22 15:17:52 -05001449
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001450 break;
1451
1452 case 13:
1453
1454 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001455 (yyval) = (yyvsp[-2]) == (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001456 }
Jamie Madill185de882014-12-22 15:17:52 -05001457
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001458 break;
1459
1460 case 14:
1461
1462 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001463 (yyval) = (yyvsp[-2]) >= (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001464 }
Jamie Madill185de882014-12-22 15:17:52 -05001465
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001466 break;
1467
1468 case 15:
1469
1470 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001471 (yyval) = (yyvsp[-2]) <= (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001472 }
Jamie Madill185de882014-12-22 15:17:52 -05001473
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001474 break;
1475
1476 case 16:
1477
1478 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001479 (yyval) = (yyvsp[-2]) > (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001480 }
Jamie Madill185de882014-12-22 15:17:52 -05001481
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001482 break;
1483
1484 case 17:
1485
1486 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001487 (yyval) = (yyvsp[-2]) < (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001488 }
Jamie Madill185de882014-12-22 15:17:52 -05001489
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001490 break;
1491
1492 case 18:
1493
1494 {
Geoff Langd4a07fb2016-09-20 10:24:23 -04001495 if ((yyvsp[-1]) < 0 || (yyvsp[0]) < 0)
Jamie Madill461e3af2016-07-21 18:15:34 -04001496 {
1497 if (!context->isIgnoringErrors())
1498 {
1499 std::ostringstream stream;
1500 stream << (yyvsp[-2]) << " >> " << (yyvsp[0]);
1501 std::string text = stream.str();
1502 context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
1503 context->token->location, text.c_str());
1504 *(context->valid) = false;
1505 }
1506 (yyval) = static_cast<YYSTYPE>(0);
1507 }
1508 else
1509 {
1510 (yyval) = (yyvsp[-2]) >> (yyvsp[0]);
1511 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001512 }
Jamie Madill185de882014-12-22 15:17:52 -05001513
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001514 break;
1515
1516 case 19:
1517
1518 {
Geoff Langd4a07fb2016-09-20 10:24:23 -04001519 if ((yyvsp[-1]) < 0 || (yyvsp[0]) < 0)
Jamie Madill461e3af2016-07-21 18:15:34 -04001520 {
1521 if (!context->isIgnoringErrors())
1522 {
1523 std::ostringstream stream;
1524 stream << (yyvsp[-2]) << " << " << (yyvsp[0]);
1525 std::string text = stream.str();
1526 context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
1527 context->token->location, text.c_str());
1528 *(context->valid) = false;
1529 }
1530 (yyval) = static_cast<YYSTYPE>(0);
1531 }
1532 else
1533 {
1534 (yyval) = (yyvsp[-2]) << (yyvsp[0]);
1535 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001536 }
Jamie Madill185de882014-12-22 15:17:52 -05001537
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001538 break;
1539
1540 case 20:
1541
1542 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001543 (yyval) = (yyvsp[-2]) - (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001544 }
Jamie Madill185de882014-12-22 15:17:52 -05001545
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001546 break;
1547
1548 case 21:
1549
1550 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001551 (yyval) = (yyvsp[-2]) + (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001552 }
Jamie Madill185de882014-12-22 15:17:52 -05001553
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001554 break;
1555
1556 case 22:
1557
1558 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001559 if ((yyvsp[0]) == 0)
1560 {
Olli Etuaho3187a382015-09-09 12:00:12 +03001561 if (!context->isIgnoringErrors())
Olli Etuaho809ec542015-08-26 14:30:57 +03001562 {
1563 std::ostringstream stream;
1564 stream << (yyvsp[-2]) << " % " << (yyvsp[0]);
1565 std::string text = stream.str();
1566 context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
1567 context->token->location,
1568 text.c_str());
Olli Etuaho247374c2015-09-09 15:07:24 +03001569 *(context->valid) = false;
Olli Etuaho809ec542015-08-26 14:30:57 +03001570 }
Olli Etuaho3187a382015-09-09 12:00:12 +03001571 (yyval) = static_cast<YYSTYPE>(0);
Olli Etuaho809ec542015-08-26 14:30:57 +03001572 }
1573 else
1574 {
1575 (yyval) = (yyvsp[-2]) % (yyvsp[0]);
1576 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001577 }
Jamie Madill185de882014-12-22 15:17:52 -05001578
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001579 break;
1580
1581 case 23:
1582
1583 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001584 if ((yyvsp[0]) == 0)
1585 {
Olli Etuaho3187a382015-09-09 12:00:12 +03001586 if (!context->isIgnoringErrors())
Olli Etuaho809ec542015-08-26 14:30:57 +03001587 {
1588 std::ostringstream stream;
1589 stream << (yyvsp[-2]) << " / " << (yyvsp[0]);
1590 std::string text = stream.str();
1591 context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
1592 context->token->location,
1593 text.c_str());
Olli Etuaho247374c2015-09-09 15:07:24 +03001594 *(context->valid) = false;
Olli Etuaho809ec542015-08-26 14:30:57 +03001595 }
Olli Etuaho3187a382015-09-09 12:00:12 +03001596 (yyval) = static_cast<YYSTYPE>(0);
Olli Etuaho809ec542015-08-26 14:30:57 +03001597 }
1598 else
1599 {
1600 (yyval) = (yyvsp[-2]) / (yyvsp[0]);
1601 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001602 }
Jamie Madill185de882014-12-22 15:17:52 -05001603
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001604 break;
1605
1606 case 24:
1607
1608 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001609 (yyval) = (yyvsp[-2]) * (yyvsp[0]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001610 }
Jamie Madill185de882014-12-22 15:17:52 -05001611
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001612 break;
1613
1614 case 25:
1615
1616 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001617 (yyval) = ! (yyvsp[0]);
Olli Etuaho6ffe6132015-08-26 14:30:57 +03001618 }
1619
1620 break;
1621
Jamie Madill9a1b49f2015-09-08 14:32:26 +00001622 case 26:
Olli Etuaho6ffe6132015-08-26 14:30:57 +03001623
1624 {
Olli Etuaho809ec542015-08-26 14:30:57 +03001625 (yyval) = ~ (yyvsp[0]);
1626 }
1627
1628 break;
1629
1630 case 27:
1631
1632 {
1633 (yyval) = - (yyvsp[0]);
1634 }
1635
1636 break;
1637
1638 case 28:
1639
1640 {
1641 (yyval) = + (yyvsp[0]);
1642 }
1643
1644 break;
1645
1646 case 29:
1647
1648 {
Jamie Madill185de882014-12-22 15:17:52 -05001649 (yyval) = (yyvsp[-1]);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001650 }
Jamie Madill185de882014-12-22 15:17:52 -05001651
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001652 break;
1653
1654
1655
1656 default: break;
1657 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001658 /* User semantic actions sometimes alter yychar, and that requires
1659 that yytoken be updated with the new translation. We take the
1660 approach of translating immediately before every use of yytoken.
1661 One alternative is translating here after every semantic action,
1662 but that translation would be missed if the semantic action invokes
1663 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1664 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1665 incorrect destructor might then be invoked immediately. In the
1666 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1667 to an incorrect destructor call or verbose syntax error message
1668 before the lookahead is translated. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001669 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1670
1671 YYPOPSTACK (yylen);
1672 yylen = 0;
1673 YY_STACK_PRINT (yyss, yyssp);
1674
1675 *++yyvsp = yyval;
1676
Jamie Madill185de882014-12-22 15:17:52 -05001677 /* Now 'shift' the result of the reduction. Determine what state
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001678 that goes to, based on the state we popped back to and the rule
1679 number reduced by. */
1680
1681 yyn = yyr1[yyn];
1682
1683 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1684 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1685 yystate = yytable[yystate];
1686 else
1687 yystate = yydefgoto[yyn - YYNTOKENS];
1688
1689 goto yynewstate;
1690
1691
Jamie Madill185de882014-12-22 15:17:52 -05001692/*--------------------------------------.
1693| yyerrlab -- here on detecting error. |
1694`--------------------------------------*/
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001695yyerrlab:
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001696 /* Make sure we have latest lookahead translation. See comments at
1697 user semantic actions for why this is necessary. */
1698 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1699
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001700 /* If not already recovering from an error, report this error. */
1701 if (!yyerrstatus)
1702 {
1703 ++yynerrs;
1704#if ! YYERROR_VERBOSE
1705 yyerror (context, YY_("syntax error"));
1706#else
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001707# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1708 yyssp, yytoken)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001709 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001710 char const *yymsgp = YY_("syntax error");
1711 int yysyntax_error_status;
1712 yysyntax_error_status = YYSYNTAX_ERROR;
1713 if (yysyntax_error_status == 0)
1714 yymsgp = yymsg;
1715 else if (yysyntax_error_status == 1)
1716 {
1717 if (yymsg != yymsgbuf)
1718 YYSTACK_FREE (yymsg);
1719 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1720 if (!yymsg)
1721 {
1722 yymsg = yymsgbuf;
1723 yymsg_alloc = sizeof yymsgbuf;
1724 yysyntax_error_status = 2;
1725 }
1726 else
1727 {
1728 yysyntax_error_status = YYSYNTAX_ERROR;
1729 yymsgp = yymsg;
1730 }
1731 }
1732 yyerror (context, yymsgp);
1733 if (yysyntax_error_status == 2)
1734 goto yyexhaustedlab;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001735 }
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001736# undef YYSYNTAX_ERROR
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001737#endif
1738 }
1739
1740
1741
1742 if (yyerrstatus == 3)
1743 {
1744 /* If just tried and failed to reuse lookahead token after an
Jamie Madill185de882014-12-22 15:17:52 -05001745 error, discard it. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001746
1747 if (yychar <= YYEOF)
Jamie Madill185de882014-12-22 15:17:52 -05001748 {
1749 /* Return failure if at end of input. */
1750 if (yychar == YYEOF)
1751 YYABORT;
1752 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001753 else
Jamie Madill185de882014-12-22 15:17:52 -05001754 {
1755 yydestruct ("Error: discarding",
1756 yytoken, &yylval, context);
1757 yychar = YYEMPTY;
1758 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001759 }
1760
1761 /* Else will try to reuse lookahead token after shifting the error
1762 token. */
1763 goto yyerrlab1;
1764
1765
1766/*---------------------------------------------------.
1767| yyerrorlab -- error raised explicitly by YYERROR. |
1768`---------------------------------------------------*/
1769yyerrorlab:
1770
1771 /* Pacify compilers like GCC when the user code never invokes
1772 YYERROR and the label yyerrorlab therefore never appears in user
1773 code. */
1774 if (/*CONSTCOND*/ 0)
1775 goto yyerrorlab;
1776
Jamie Madill185de882014-12-22 15:17:52 -05001777 /* Do not reclaim the symbols of the rule whose action triggered
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001778 this YYERROR. */
1779 YYPOPSTACK (yylen);
1780 yylen = 0;
1781 YY_STACK_PRINT (yyss, yyssp);
1782 yystate = *yyssp;
1783 goto yyerrlab1;
1784
1785
1786/*-------------------------------------------------------------.
1787| yyerrlab1 -- common code for both syntax error and YYERROR. |
1788`-------------------------------------------------------------*/
1789yyerrlab1:
Jamie Madill185de882014-12-22 15:17:52 -05001790 yyerrstatus = 3; /* Each real token shifted decrements this. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001791
1792 for (;;)
1793 {
1794 yyn = yypact[yystate];
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001795 if (!yypact_value_is_default (yyn))
Jamie Madill185de882014-12-22 15:17:52 -05001796 {
1797 yyn += YYTERROR;
1798 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1799 {
1800 yyn = yytable[yyn];
1801 if (0 < yyn)
1802 break;
1803 }
1804 }
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001805
1806 /* Pop the current state because it cannot handle the error token. */
1807 if (yyssp == yyss)
Jamie Madill185de882014-12-22 15:17:52 -05001808 YYABORT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001809
1810
1811 yydestruct ("Error: popping",
Jamie Madill185de882014-12-22 15:17:52 -05001812 yystos[yystate], yyvsp, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001813 YYPOPSTACK (1);
1814 yystate = *yyssp;
1815 YY_STACK_PRINT (yyss, yyssp);
1816 }
1817
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001818 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001819 *++yyvsp = yylval;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001820 YY_IGNORE_MAYBE_UNINITIALIZED_END
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001821
1822
1823 /* Shift the error token. */
1824 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1825
1826 yystate = yyn;
1827 goto yynewstate;
1828
1829
1830/*-------------------------------------.
1831| yyacceptlab -- YYACCEPT comes here. |
1832`-------------------------------------*/
1833yyacceptlab:
1834 yyresult = 0;
1835 goto yyreturn;
1836
1837/*-----------------------------------.
1838| yyabortlab -- YYABORT comes here. |
1839`-----------------------------------*/
1840yyabortlab:
1841 yyresult = 1;
1842 goto yyreturn;
1843
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001844#if !defined yyoverflow || YYERROR_VERBOSE
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001845/*-------------------------------------------------.
1846| yyexhaustedlab -- memory exhaustion comes here. |
1847`-------------------------------------------------*/
1848yyexhaustedlab:
1849 yyerror (context, YY_("memory exhausted"));
1850 yyresult = 2;
1851 /* Fall through. */
1852#endif
1853
1854yyreturn:
1855 if (yychar != YYEMPTY)
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001856 {
1857 /* Make sure we have latest lookahead translation. See comments at
1858 user semantic actions for why this is necessary. */
1859 yytoken = YYTRANSLATE (yychar);
1860 yydestruct ("Cleanup: discarding lookahead",
1861 yytoken, &yylval, context);
1862 }
Jamie Madill185de882014-12-22 15:17:52 -05001863 /* Do not reclaim the symbols of the rule whose action triggered
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001864 this YYABORT or YYACCEPT. */
1865 YYPOPSTACK (yylen);
1866 YY_STACK_PRINT (yyss, yyssp);
1867 while (yyssp != yyss)
1868 {
1869 yydestruct ("Cleanup: popping",
Jamie Madill185de882014-12-22 15:17:52 -05001870 yystos[*yyssp], yyvsp, context);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001871 YYPOPSTACK (1);
1872 }
1873#ifndef yyoverflow
1874 if (yyss != yyssa)
1875 YYSTACK_FREE (yyss);
1876#endif
1877#if YYERROR_VERBOSE
1878 if (yymsg != yymsgbuf)
1879 YYSTACK_FREE (yymsg);
1880#endif
Jamie Madill185de882014-12-22 15:17:52 -05001881 return yyresult;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001882}
1883
1884
1885
Zhenyao Mod526f982014-05-13 14:51:19 -07001886int yylex(YYSTYPE *lvalp, Context *context)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001887{
Olli Etuaho3187a382015-09-09 12:00:12 +03001888 pp::Token *token = context->token;
Olli Etuaho247374c2015-09-09 15:07:24 +03001889 if (!context->parsePresetToken)
1890 {
1891 context->lexer->lex(token);
1892 }
1893 context->parsePresetToken = false;
Olli Etuaho3187a382015-09-09 12:00:12 +03001894
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001895 int type = 0;
1896
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001897 switch (token->type)
1898 {
Zhenyao Mod526f982014-05-13 14:51:19 -07001899 case pp::Token::CONST_INT: {
alokp@chromium.org2e818912012-06-29 21:26:03 +00001900 unsigned int val = 0;
Olli Etuaho247374c2015-09-09 15:07:24 +03001901 int testVal = 0;
1902 if (!token->uValue(&val) || (!token->iValue(&testVal) &&
1903 context->errorSettings.integerLiteralsMustFit32BitSignedRange))
alokp@chromium.org2e818912012-06-29 21:26:03 +00001904 {
Shannon Woods7f2d7942013-11-19 15:07:58 -05001905 context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
alokp@chromium.org2e818912012-06-29 21:26:03 +00001906 token->location, token->text);
Olli Etuaho247374c2015-09-09 15:07:24 +03001907 *(context->valid) = false;
alokp@chromium.org2e818912012-06-29 21:26:03 +00001908 }
1909 *lvalp = static_cast<YYSTYPE>(val);
maxvujovic@gmail.come640ef82012-07-13 18:42:40 +00001910 type = TOK_CONST_INT;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001911 break;
alokp@chromium.org2e818912012-06-29 21:26:03 +00001912 }
Olli Etuaho809ec542015-08-26 14:30:57 +03001913 case pp::Token::IDENTIFIER:
Olli Etuaho809ec542015-08-26 14:30:57 +03001914 *lvalp = static_cast<YYSTYPE>(-1);
1915 type = TOK_IDENTIFIER;
1916 break;
Zhenyao Mod526f982014-05-13 14:51:19 -07001917 case pp::Token::OP_OR:
1918 type = TOK_OP_OR;
1919 break;
1920 case pp::Token::OP_AND:
1921 type = TOK_OP_AND;
1922 break;
1923 case pp::Token::OP_NE:
1924 type = TOK_OP_NE;
1925 break;
1926 case pp::Token::OP_EQ:
1927 type = TOK_OP_EQ;
1928 break;
1929 case pp::Token::OP_GE:
1930 type = TOK_OP_GE;
1931 break;
1932 case pp::Token::OP_LE:
1933 type = TOK_OP_LE;
1934 break;
1935 case pp::Token::OP_RIGHT:
1936 type = TOK_OP_RIGHT;
1937 break;
1938 case pp::Token::OP_LEFT:
1939 type = TOK_OP_LEFT;
1940 break;
1941 case '|':
1942 case '^':
1943 case '&':
1944 case '>':
1945 case '<':
1946 case '-':
1947 case '+':
1948 case '%':
1949 case '/':
1950 case '*':
1951 case '!':
1952 case '~':
1953 case '(':
1954 case ')':
1955 type = token->type;
1956 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001957
Zhenyao Mod526f982014-05-13 14:51:19 -07001958 default:
1959 break;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001960 }
1961
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001962 return type;
1963}
1964
Zhenyao Mod526f982014-05-13 14:51:19 -07001965void yyerror(Context *context, const char *reason)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001966{
Shannon Woods7f2d7942013-11-19 15:07:58 -05001967 context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001968 context->token->location,
1969 reason);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001970}
1971
1972namespace pp {
1973
Zhenyao Mod526f982014-05-13 14:51:19 -07001974ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics)
1975 : mLexer(lexer),
1976 mDiagnostics(diagnostics)
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001977{
1978}
1979
Olli Etuaho247374c2015-09-09 15:07:24 +03001980bool ExpressionParser::parse(Token *token,
1981 int *result,
1982 bool parsePresetToken,
1983 const ErrorSettings &errorSettings,
1984 bool *valid)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001985{
1986 Context context;
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00001987 context.diagnostics = mDiagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001988 context.lexer = mLexer;
1989 context.token = token;
1990 context.result = result;
Olli Etuaho809ec542015-08-26 14:30:57 +03001991 context.ignoreErrors = 0;
Olli Etuaho247374c2015-09-09 15:07:24 +03001992 context.parsePresetToken = parsePresetToken;
1993 context.errorSettings = errorSettings;
1994 context.valid = valid;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001995 int ret = yyparse(&context);
1996 switch (ret)
1997 {
1998 case 0:
1999 case 1:
2000 break;
2001
2002 case 2:
Shannon Woods7f2d7942013-11-19 15:07:58 -05002003 mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002004 break;
2005
2006 default:
2007 assert(false);
Shannon Woods7f2d7942013-11-19 15:07:58 -05002008 mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002009 break;
2010 }
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00002011
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002012 return ret == 0;
2013}
2014
2015} // namespace pp