summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2015-02-15 17:57:53 -0600
committerNicolas Williams <nico@cryptonector.com>2015-02-15 18:34:44 -0600
commit8cef5a37ab9d53ee81500b93f44e410c7814a512 (patch)
treebc4cd1706f10ec47acba98565b9399e92796a93e /parser.c
parent8afdeee785140f3f916321f2a24b4c02d99131ee (diff)
Add --disable-maintainer-mode; make bison optional
Also flex is now optional. The outputs of flex and bison are now committed. By default they get built, but users who want to build from git can now ./configure --disable-maintainer-mode to turn off the dependency on bison and flex. Maintainers must, of course, commit the bison and/or flex outputs when they make changes to parser.y and/or lexer.l, respectively.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c3537
1 files changed, 3537 insertions, 0 deletions
diff --git a/parser.c b/parser.c
new file mode 100644
index 00000000..1f8005ce
--- /dev/null
+++ b/parser.c
@@ -0,0 +1,3537 @@
+/* A Bison parser, made by GNU Bison 3.0.2. */
+
+/* Bison implementation for Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "3.0.2"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 1
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+
+
+
+/* Copy the first part of user declarations. */
+#line 1 "parser.y" /* yacc.c:339 */
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include "compile.h"
+#include "jv_alloc.h"
+#define YYMALLOC jv_mem_alloc
+#define YYFREE jv_mem_free
+
+#line 76 "parser.c" /* yacc.c:339 */
+
+# ifndef YY_NULLPTR
+# if defined __cplusplus && 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
+# endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 1
+#endif
+
+/* In a future release of Bison, this section will be replaced
+ by #include "y.tab.h". */
+#ifndef YY_YY_PARSER_H_INCLUDED
+# define YY_YY_PARSER_H_INCLUDED
+/* Debug traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+#if YYDEBUG
+extern int yydebug;
+#endif
+/* "%code requires" blocks. */
+#line 10 "parser.y" /* yacc.c:355 */
+
+#include "locfile.h"
+struct lexer_param;
+
+#define YYLTYPE location
+#define YYLLOC_DEFAULT(Loc, Rhs, N) \
+ do { \
+ if (N) { \
+ (Loc).start = YYRHSLOC(Rhs, 1).start; \
+ (Loc).end = YYRHSLOC(Rhs, N).end; \
+ } else { \
+ (Loc).start = YYRHSLOC(Rhs, 0).end; \
+ (Loc).end = YYRHSLOC(Rhs, 0).end; \
+ } \
+ } while (0)
+
+
+#line 124 "parser.c" /* yacc.c:355 */
+
+/* Token type. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ enum yytokentype
+ {
+ INVALID_CHARACTER = 258,
+ IDENT = 259,
+ FIELD = 260,
+ LITERAL = 261,
+ FORMAT = 262,
+ REC = 263,
+ SETMOD = 264,
+ EQ = 265,
+ NEQ = 266,
+ DEFINEDOR = 267,
+ AS = 268,
+ DEF = 269,
+ MODULE = 270,
+ IMPORT = 271,
+ IF = 272,
+ THEN = 273,
+ ELSE = 274,
+ ELSE_IF = 275,
+ REDUCE = 276,
+ FOREACH = 277,
+ END = 278,
+ AND = 279,
+ OR = 280,
+ TRY = 281,
+ CATCH = 282,
+ LABEL = 283,
+ BREAK = 284,
+ BREAK2 = 285,
+ BREAK3 = 286,
+ SETPIPE = 287,
+ SETPLUS = 288,
+ SETMINUS = 289,
+ SETMULT = 290,
+ SETDIV = 291,
+ SETDEFINEDOR = 292,
+ LESSEQ = 293,
+ GREATEREQ = 294,
+ QQSTRING_START = 295,
+ QQSTRING_TEXT = 296,
+ QQSTRING_INTERP_START = 297,
+ QQSTRING_INTERP_END = 298,
+ QQSTRING_END = 299
+ };
+#endif
+/* Tokens. */
+#define INVALID_CHARACTER 258
+#define IDENT 259
+#define FIELD 260
+#define LITERAL 261
+#define FORMAT 262
+#define REC 263
+#define SETMOD 264
+#define EQ 265
+#define NEQ 266
+#define DEFINEDOR 267
+#define AS 268
+#define DEF 269
+#define MODULE 270
+#define IMPORT 271
+#define IF 272
+#define THEN 273
+#define ELSE 274
+#define ELSE_IF 275
+#define REDUCE 276
+#define FOREACH 277
+#define END 278
+#define AND 279
+#define OR 280
+#define TRY 281
+#define CATCH 282
+#define LABEL 283
+#define BREAK 284
+#define BREAK2 285
+#define BREAK3 286
+#define SETPIPE 287
+#define SETPLUS 288
+#define SETMINUS 289
+#define SETMULT 290
+#define SETDIV 291
+#define SETDEFINEDOR 292
+#define LESSEQ 293
+#define GREATEREQ 294
+#define QQSTRING_START 295
+#define QQSTRING_TEXT 296
+#define QQSTRING_INTERP_START 297
+#define QQSTRING_INTERP_END 298
+#define QQSTRING_END 299
+
+/* Value type. */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE YYSTYPE;
+union YYSTYPE
+{
+#line 30 "parser.y" /* yacc.c:355 */
+
+ jv literal;
+ block blk;
+
+#line 229 "parser.c" /* yacc.c:355 */
+};
+# define YYSTYPE_IS_TRIVIAL 1
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* Location type. */
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
+typedef struct YYLTYPE YYLTYPE;
+struct YYLTYPE
+{
+ int first_line;
+ int first_column;
+ int last_line;
+ int last_column;
+};
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+int yyparse (block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr);
+
+#endif /* !YY_YY_PARSER_H_INCLUDED */
+
+/* Copy the second part of user declarations. */
+#line 112 "parser.y" /* yacc.c:358 */
+
+#include "lexer.h"
+struct lexer_param {
+ yyscan_t lexer;
+};
+#define FAIL(loc, msg) \
+ do { \
+ location l = loc; \
+ yyerror(&l, answer, errors, locations, lexer_param_ptr, msg); \
+ /*YYERROR*/; \
+ } while (0)
+
+void yyerror(YYLTYPE* loc, block* answer, int* errors,
+ struct locfile* locations, struct lexer_param* lexer_param_ptr, const char *s){
+ (*errors)++;
+ if (strstr(s, "unexpected")) {
+#ifdef WIN32
+ locfile_locate(locations, *loc, "jq: error: %s (Windows cmd shell quoting issues?)", s);
+#else
+ locfile_locate(locations, *loc, "jq: error: %s (Unix shell quoting issues?)", s);
+#endif
+ } else {
+ locfile_locate(locations, *loc, "jq: error: %s", s);
+ }
+}
+
+int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, block* answer, int* errors,
+ struct locfile* locations, struct lexer_param* lexer_param_ptr) {
+ yyscan_t lexer = lexer_param_ptr->lexer;
+ int tok = jq_yylex(yylval, yylloc, lexer);
+ if ((tok == LITERAL || tok == QQSTRING_TEXT) && !jv_is_valid(yylval->literal)) {
+ jv msg = jv_invalid_get_msg(jv_copy(yylval->literal));
+ if (jv_get_kind(msg) == JV_KIND_STRING) {
+ FAIL(*yylloc, jv_string_value(msg));
+ } else {
+ FAIL(*yylloc, "Invalid literal");
+ }
+ jv_free(msg);
+ jv_free(yylval->literal);
+ yylval->literal = jv_null();
+ }
+ return tok;
+}
+
+static unsigned int next_label = 0;
+
+static block gen_dictpair(block k, block v) {
+ return BLOCK(gen_subexp(k), gen_subexp(v), gen_op_simple(INSERT));
+}
+
+static block gen_index(block obj, block key) {
+ return BLOCK(gen_subexp(key), obj, gen_op_simple(INDEX));
+}
+
+static block gen_index_opt(block obj, block key) {
+ return BLOCK(gen_subexp(key), obj, gen_op_simple(INDEX_OPT));
+}
+
+static block gen_slice_index(block obj, block start, block end, opcode idx_op) {
+ block key = BLOCK(gen_subexp(gen_const(jv_object())),
+ gen_subexp(gen_const(jv_string("start"))),
+ gen_subexp(start),
+ gen_op_simple(INSERT),
+ gen_subexp(gen_const(jv_string("end"))),
+ gen_subexp(end),
+ gen_op_simple(INSERT));
+ return BLOCK(key, obj, gen_op_simple(idx_op));
+}
+
+static block constant_fold(block a, block b, int op) {
+ if (!block_is_single(a) || !block_is_const(a) ||
+ !block_is_single(b) || !block_is_const(b))
+ return gen_noop();
+ if (block_const_kind(a) != block_const_kind(b))
+ return gen_noop();
+
+ jv res = jv_invalid();
+
+ if (block_const_kind(a) == JV_KIND_NUMBER) {
+ double na = jv_number_value(block_const(a));
+ double nb = jv_number_value(block_const(b));
+ switch (op) {
+ case '+': res = jv_number(na + nb); break;
+ case '-': res = jv_number(na - nb); break;
+ case '*': res = jv_number(na * nb); break;
+ case '/': res = jv_number(na / nb); break;
+ case EQ: res = (na == nb ? jv_true() : jv_false()); break;
+ case NEQ: res = (na != nb ? jv_true() : jv_false()); break;
+ case '<': res = (na < nb ? jv_true() : jv_false()); break;
+ case '>': res = (na > nb ? jv_true() : jv_false()); break;
+ case LESSEQ: res = (na <= nb ? jv_true() : jv_false()); break;
+ case GREATEREQ: res = (na >= nb ? jv_true() : jv_false()); break;
+ default: break;
+ }
+ } else if (op == '+' && block_const_kind(a) == JV_KIND_STRING) {
+ res = jv_string_concat(block_const(a), block_const(b));
+ } else {
+ return gen_noop();
+ }
+
+ if (jv_get_kind(res) == JV_KIND_INVALID)
+ return gen_noop();
+
+ block_free(a);
+ block_free(b);
+ return gen_const(res);
+}
+
+static block gen_binop(block a, block b, int op) {
+ block folded = constant_fold(a, b, op);
+ if (!block_is_noop(folded))
+ return folded;
+
+ const char* funcname = 0;
+ switch (op) {
+ case '+': funcname = "_plus"; break;
+ case '-': funcname = "_minus"; break;
+ case '*': funcname = "_multiply"; break;
+ case '/': funcname = "_divide"; break;
+ case '%': funcname = "_mod"; break;
+ case EQ: funcname = "_equal"; break;
+ case NEQ: funcname = "_notequal"; break;
+ case '<': funcname = "_less"; break;
+ case '>': funcname = "_greater"; break;
+ case LESSEQ: funcname = "_lesseq"; break;
+ case GREATEREQ: funcname = "_greatereq"; break;
+ }
+ assert(funcname);
+
+ return gen_call(funcname, BLOCK(gen_lambda(a), gen_lambda(b)));
+}
+
+static block gen_format(block a, jv fmt) {
+ return BLOCK(a, gen_call("format", BLOCK(gen_lambda(gen_const(fmt)))));
+}
+
+static block gen_definedor_assign(block object, block val) {
+ block tmp = gen_op_var_fresh(STOREV, "tmp");
+ return BLOCK(gen_op_simple(DUP),
+ val, tmp,
+ gen_call("_modify", BLOCK(gen_lambda(object),
+ gen_lambda(gen_definedor(gen_noop(),
+ gen_op_bound(LOADV, tmp))))));
+}
+
+static block gen_update(block object, block val, int optype) {
+ block tmp = gen_op_var_fresh(STOREV, "tmp");
+ return BLOCK(gen_op_simple(DUP),
+ val,
+ tmp,
+ gen_call("_modify", BLOCK(gen_lambda(object),
+ gen_lambda(gen_binop(gen_noop(),
+ gen_op_bound(LOADV, tmp),
+ optype)))));
+}
+
+
+#line 414 "parser.c" /* yacc.c:358 */
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#else
+typedef signed char yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(Msgid) Msgid
+# endif
+#endif
+
+#ifndef YY_ATTRIBUTE
+# if (defined __GNUC__ \
+ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
+ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
+# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+# else
+# define YY_ATTRIBUTE(Spec) /* empty */
+# endif
+#endif
+
+#ifndef YY_ATTRIBUTE_PURE
+# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
+#endif
+
+#ifndef YY_ATTRIBUTE_UNUSED
+# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
+#endif
+
+#if !defined _Noreturn \
+ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
+# if defined _MSC_VER && 1200 <= _MSC_VER
+# define _Noreturn __declspec (noreturn)
+# else
+# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(E) ((void) (E))
+#else
+# define YYUSE(E) /* empty */
+#endif
+
+#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+/* Suppress an incorrect diagnostic about yylval being uninitialized. */
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+ _Pragma ("GCC diagnostic pop")
+#else
+# define YY_INITIAL_VALUE(Value) Value
+#endif
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
+#endif
+#ifndef YY_INITIAL_VALUE
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
+#endif
+
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's 'empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
+ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+ YYLTYPE yyls_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ + 2 * YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (0)
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from SRC to DST. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(Dst, Src, Count) \
+ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
+# else
+# define YYCOPY(Dst, Src, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (Dst)[yyi] = (Src)[yyi]; \
+ } \
+ while (0)
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 29
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 1871
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 66
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 21
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 123
+/* YYNSTATES -- Number of states. */
+#define YYNSTATES 256
+
+/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
+ by yylex, with out-of-bounds checking. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 299
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, without out-of-bounds checking. */
+static const yytype_uint8 yytranslate[] =
+{
+ 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, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 57, 54, 2, 2,
+ 58, 59, 52, 50, 46, 51, 61, 53, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 60, 56,
+ 48, 47, 49, 55, 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, 62, 2, 63, 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, 2, 2, 64, 45, 65, 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, 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,
+ 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, 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, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44
+};
+
+#if YYDEBUG
+ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 272, 272, 275, 280, 283, 293, 296, 301, 304,
+ 309, 313, 318, 323, 328, 333, 336, 341, 345, 349,
+ 354, 360, 372, 376, 380, 384, 388, 392, 396, 400,
+ 404, 408, 412, 416, 420, 424, 428, 432, 436, 440,
+ 444, 448, 452, 456, 460, 464, 468, 472, 476, 481,
+ 490, 497, 509, 523, 528, 534, 537, 542, 547, 554,
+ 554, 558, 558, 565, 568, 571, 577, 580, 585, 588,
+ 591, 597, 600, 603, 608, 613, 618, 626, 629, 632,
+ 635, 638, 641, 644, 647, 650, 654, 660, 663, 666,
+ 669, 672, 675, 678, 681, 684, 687, 690, 693, 696,
+ 699, 702, 705, 708, 715, 719, 731, 736, 737, 738,
+ 739, 742, 745, 750, 755, 758, 759, 760, 763, 766,
+ 769, 773, 777, 780
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || 1
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "INVALID_CHARACTER", "IDENT", "FIELD",
+ "LITERAL", "FORMAT", "\"..\"", "\"%=\"", "\"==\"", "\"!=\"", "\"//\"",
+ "\"as\"", "\"def\"", "\"module\"", "\"import\"", "\"if\"", "\"then\"",
+ "\"else\"", "\"elif\"", "\"reduce\"", "\"foreach\"", "\"end\"",
+ "\"and\"", "\"or\"", "\"try\"", "\"catch\"", "\"label\"", "\"break\"",
+ "\"break2\"", "\"break3\"", "\"|=\"", "\"+=\"", "\"-=\"", "\"*=\"",
+ "\"/=\"", "\"//=\"", "\"<=\"", "\">=\"", "QQSTRING_START",
+ "QQSTRING_TEXT", "QQSTRING_INTERP_START", "QQSTRING_INTERP_END",
+ "QQSTRING_END", "'|'", "','", "'='", "'<'", "'>'", "'+'", "'-'", "'*'",
+ "'/'", "'%'", "'?'", "';'", "'$'", "'('", "')'", "':'", "'.'", "'['",
+ "']'", "'{'", "'}'", "$accept", "TopLevel", "Module", "Imports",
+ "FuncDefs", "Exp", "Import", "FuncDef", "Params", "Param", "String",
+ "@1", "@2", "QQString", "ElseBody", "ExpD", "Term", "Args", "Arg",
+ "MkDict", "MkDictPair", YY_NULLPTR
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[NUM] -- (External) token number corresponding to the
+ (internal) symbol number NUM (which must be that of a token). */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+ 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
+ 295, 296, 297, 298, 299, 124, 44, 61, 60, 62,
+ 43, 45, 42, 47, 37, 63, 59, 36, 40, 41,
+ 58, 46, 91, 93, 123, 125
+};
+# endif
+
+#define YYPACT_NINF -122
+
+#define yypact_value_is_default(Yystate) \
+ (!!((Yystate) == (-122)))
+
+#define YYTABLE_NINF -115
+
+#define yytable_value_is_error(Yytable_value) \
+ (!!((Yytable_value) == (-115)))
+
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+static const yytype_int16 yypact[] =
+{
+ 8, 851, 10, 0, 27, -41, -122, 12, -122, 35,
+ 851, 463, 463, 851, -44, 50, -122, -122, -122, 851,
+ 49, 421, 230, 357, 47, 1193, 851, -122, -2, -122,
+ -3, 851, 0, 851, -122, -122, 58, 1576, 33, 36,
+ 77, 851, 106, 107, -122, -19, -122, 56, 1065, -122,
+ 118, 12, 66, 59, -122, 918, -39, 63, 483, 64,
+ 60, 82, 851, 851, 851, 851, 851, 851, 851, 851,
+ 851, 851, 851, 851, 851, 851, 851, 851, 851, 851,
+ 851, 851, 851, 851, 851, 851, -122, -122, 1734, 74,
+ 73, -3, 293, 120, -122, 1734, 851, -122, 1734, -35,
+ -122, -122, 51, 851, 545, 78, 79, 607, 1734, 86,
+ -122, -13, -122, -122, -122, -122, -122, -122, 92, -122,
+ 155, 75, 1097, 155, -122, 92, 1798, 1033, 1033, 1766,
+ 1816, 116, 1798, 1798, 1798, 1798, 1798, 1798, 1033, 1033,
+ 1734, 1766, 1798, 1033, 1033, -19, -19, 83, 83, 83,
+ -122, 133, 84, 80, 851, 87, 886, 52, -122, 851,
+ -122, 1, -122, 137, -9, -122, 1241, -122, 1529, 140,
+ 141, -122, -122, 851, -122, 851, -122, 100, -122, 155,
+ 102, 39, 88, 89, 102, -122, 111, -122, -122, 950,
+ -122, 668, 96, 729, 148, -122, -122, -122, 51, 115,
+ -122, 851, 851, -122, 119, 121, 1734, 1608, -122, 155,
+ 155, 155, 851, 123, 125, 982, -122, -122, 1289, 790,
+ -122, 851, 1655, 1702, 851, 851, -122, 102, 102, 102,
+ 1734, -122, -122, 126, -122, -122, 1337, 1385, -122, 851,
+ 1433, 1481, -122, -122, -122, 1529, 851, 851, -122, 1129,
+ 1014, -122, 851, -122, 1161, -122
+};
+
+ /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE does not specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 4, 0, 0, 6, 105, 82, 97, 99, 72, 0,
+ 0, 0, 0, 0, 0, 73, 74, 75, 59, 0,
+ 0, 0, 0, 0, 0, 0, 0, 98, 48, 1,
+ 0, 8, 6, 0, 78, 61, 0, 0, 0, 0,
+ 18, 0, 0, 0, 63, 33, 104, 0, 0, 85,
+ 0, 0, 84, 0, 102, 0, 0, 121, 0, 120,
+ 0, 115, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 22, 5, 10, 81,
+ 0, 0, 0, 0, 3, 2, 8, 7, 113, 0,
+ 111, 63, 0, 0, 0, 0, 0, 0, 20, 0,
+ 76, 0, 107, 100, 86, 80, 108, 101, 0, 110,
+ 0, 0, 0, 0, 103, 0, 41, 42, 43, 26,
+ 25, 24, 28, 32, 35, 37, 40, 27, 46, 47,
+ 29, 30, 23, 44, 45, 31, 34, 36, 38, 39,
+ 77, 0, 83, 0, 0, 90, 0, 0, 9, 0,
+ 106, 0, 58, 0, 0, 55, 0, 16, 0, 0,
+ 0, 19, 17, 0, 64, 0, 60, 0, 117, 0,
+ 118, 70, 0, 0, 119, 116, 0, 79, 109, 0,
+ 89, 0, 88, 0, 0, 112, 62, 57, 0, 0,
+ 53, 0, 0, 15, 0, 0, 21, 0, 69, 0,
+ 0, 0, 0, 96, 95, 0, 87, 50, 0, 0,
+ 56, 0, 0, 0, 0, 0, 65, 68, 123, 122,
+ 11, 93, 92, 94, 51, 49, 0, 0, 67, 0,
+ 0, 0, 91, 52, 54, 0, 0, 0, 66, 0,
+ 0, 12, 0, 14, 0, 13
+};
+
+ /* YYPGOTO[NTERM-NUM]. */
+static const yytype_int16 yypgoto[] =
+{
+ -122, -122, -122, 144, 91, -1, -122, -4, -122, -16,
+ -5, -122, -122, 90, -62, -121, -6, -122, 29, -110,
+ -122
+};
+
+ /* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int16 yydefgoto[] =
+{
+ -1, 2, 3, 31, 94, 88, 32, 26, 164, 165,
+ 27, 44, 101, 111, 203, 180, 28, 99, 100, 60,
+ 61
+};
+
+ /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule whose
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+static const yytype_int16 yytable[] =
+{
+ 25, 41, 184, 89, 51, 38, 39, 118, 178, 37,
+ 29, 90, 40, 42, 34, 185, 30, 52, 45, 59,
+ 48, 159, 55, 1, 160, 93, 119, 96, 174, 175,
+ 95, 176, 98, 83, 84, 85, 86, 18, 89, 36,
+ 108, 89, 174, 175, 89, 196, 105, 198, 56, 106,
+ 199, 57, 35, 46, 51, 162, 193, 122, 208, 91,
+ 92, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
+ 145, 146, 147, 148, 149, 33, 152, 18, 227, 228,
+ 229, 156, 96, 177, 91, 92, 57, 91, 92, 51,
+ 91, 92, 166, 168, 107, 58, 172, 43, 163, 194,
+ 109, 110, -114, 59, 181, 112, 102, 181, 103, 114,
+ 59, 115, 116, 120, 123, 124, 63, 64, 125, 150,
+ 151, 173, 18, 157, 182, 169, 170, 186, 86, 187,
+ 66, 197, 190, 188, 204, 205, 118, 209, 210, 211,
+ 58, 216, 219, 189, 74, 75, 212, -114, 98, 4,
+ 5, 6, 7, 8, 79, 80, 81, 82, 83, 84,
+ 85, 86, 206, 181, 207, 221, 97, 224, 231, 225,
+ 232, 242, 220, 248, 15, 16, 17, 158, 195, 0,
+ 215, 161, 218, 0, 0, 18, 0, 0, 0, 0,
+ 222, 223, 0, 181, 181, 181, 179, 0, 0, 0,
+ 0, 230, 20, 21, 0, 0, 22, 23, 236, 24,
+ 237, 0, 0, 240, 241, 0, 0, 0, 0, 0,
+ -71, 49, 0, 0, 50, -71, 0, 51, 245, -71,
+ -71, -71, -71, -71, 0, 249, 250, 0, -71, -71,
+ -71, 254, 0, -71, -71, -71, 0, -71, 0, 0,
+ 0, 0, -71, -71, -71, -71, -71, -71, -71, -71,
+ 18, 0, 0, -71, 0, -71, -71, -71, -71, -71,
+ -71, -71, -71, -71, -71, -71, -71, 0, 0, -71,
+ -71, -71, -71, -71, 153, -71, 0, 4, 5, 6,
+ 7, 8, 0, 0, 0, 0, 0, 9, 0, 0,
+ 10, 0, 0, 0, 11, 12, 0, 0, 0, 13,
+ 0, 14, 15, 16, 17, 0, 0, 0, 0, 0,
+ 0, 0, 0, 18, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 19, 0, 0, 0, 0, 0,
+ 20, 21, 0, 154, 22, 23, 155, 24, 53, 0,
+ 0, 4, 5, 6, 7, 8, 0, 0, 0, 0,
+ 0, 9, 0, 0, 10, 0, 0, 0, 11, 12,
+ 0, 0, 0, 13, 0, 14, 15, 16, 17, 0,
+ 0, 0, 0, 0, 0, 0, 0, 18, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 19, 0,
+ 0, 0, 0, 0, 20, 21, 0, 0, 22, 23,
+ 54, 24, 47, 0, 0, 4, 5, 6, 7, 8,
+ 0, 0, 0, 0, 0, 9, 0, 0, 10, 0,
+ 0, 0, 11, 12, 0, 0, 0, 13, 0, 14,
+ 15, 16, 17, 0, 0, 0, 0, 0, 0, 0,
+ 0, 18, 0, 0, 0, 0, 0, 4, 5, 6,
+ 7, 8, 19, 0, 0, 0, 0, 0, 20, 21,
+ 0, 0, 22, 23, 121, 24, 0, 4, 5, 6,
+ 7, 8, 15, 16, 17, 0, 0, 9, 0, 0,
+ 10, 0, 0, 18, 11, 12, 0, 0, 0, 13,
+ 0, 14, 15, 16, 17, 0, 0, 0, 0, 0,
+ 20, 21, 0, 18, 22, 23, 0, 24, 0, 0,
+ 0, 0, 0, 0, 19, 0, 0, 0, 0, 0,
+ 20, 21, 0, 0, 22, 23, 167, 24, 0, 4,
+ 5, 6, 7, 8, 0, 0, 0, 0, 0, 9,
+ 0, 0, 10, 0, 0, 0, 11, 12, 0, 0,
+ 0, 13, 0, 14, 15, 16, 17, 0, 0, 0,
+ 0, 0, 0, 0, 0, 18, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 19, 0, 0, 0,
+ 0, 0, 20, 21, 0, 0, 22, 23, 171, 24,
+ 0, 4, 5, 6, 7, 8, 0, 0, 0, 0,
+ 0, 9, 0, 0, 10, 0, 0, 0, 11, 12,
+ 0, 0, 0, 13, 0, 14, 15, 16, 17, 0,
+ 0, 0, 0, 0, 0, 0, 0, 18, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 19, 0,
+ 0, 0, 0, 0, 20, 21, 0, 0, 22, 23,
+ 0, 24, 4, 5, 6, 7, 8, 0, 0, 0,
+ 0, 0, 9, 0, 0, 10, 0, 0, 0, 11,
+ 12, 0, 0, 0, 13, 0, 14, 15, 16, 17,
+ 0, 0, 0, 0, 0, 0, 0, 0, 18, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 19,
+ 0, 0, 0, 0, 0, 20, 21, 0, 0, 22,
+ 23, 214, 24, 4, 5, 6, 7, 8, 0, 0,
+