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