Previously, bindings were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes #2675
215 lines
6.7 KiB
C
Generated
215 lines
6.7 KiB
C
Generated
/* A Bison parser, made by GNU Bison 3.8.2. */
|
|
|
|
/* Bison interface for Yacc-like parsers in C
|
|
|
|
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 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 <https://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. */
|
|
|
|
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
|
especially those whose name start with YY_ or yy_. They are
|
|
private implementation details that can be changed or removed. */
|
|
|
|
#ifndef YY_YY_SRC_PARSER_H_INCLUDED
|
|
# define YY_YY_SRC_PARSER_H_INCLUDED
|
|
/* Debug traces. */
|
|
#ifndef YYDEBUG
|
|
# define YYDEBUG 0
|
|
#endif
|
|
#if YYDEBUG
|
|
extern int yydebug;
|
|
#endif
|
|
/* "%code requires" blocks. */
|
|
#line 11 "src/parser.y"
|
|
|
|
#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 66 "src/parser.h"
|
|
|
|
/* Token kinds. */
|
|
#ifndef YYTOKENTYPE
|
|
# define YYTOKENTYPE
|
|
enum yytokentype
|
|
{
|
|
YYEMPTY = -2,
|
|
YYEOF = 0, /* "end of file" */
|
|
YYerror = 256, /* error */
|
|
YYUNDEF = 257, /* "invalid token" */
|
|
INVALID_CHARACTER = 258, /* INVALID_CHARACTER */
|
|
IDENT = 259, /* IDENT */
|
|
FIELD = 260, /* FIELD */
|
|
BINDING = 261, /* BINDING */
|
|
LITERAL = 262, /* LITERAL */
|
|
FORMAT = 263, /* FORMAT */
|
|
REC = 264, /* ".." */
|
|
SETMOD = 265, /* "%=" */
|
|
EQ = 266, /* "==" */
|
|
NEQ = 267, /* "!=" */
|
|
DEFINEDOR = 268, /* "//" */
|
|
AS = 269, /* "as" */
|
|
DEF = 270, /* "def" */
|
|
MODULE = 271, /* "module" */
|
|
IMPORT = 272, /* "import" */
|
|
INCLUDE = 273, /* "include" */
|
|
IF = 274, /* "if" */
|
|
THEN = 275, /* "then" */
|
|
ELSE = 276, /* "else" */
|
|
ELSE_IF = 277, /* "elif" */
|
|
REDUCE = 278, /* "reduce" */
|
|
FOREACH = 279, /* "foreach" */
|
|
END = 280, /* "end" */
|
|
AND = 281, /* "and" */
|
|
OR = 282, /* "or" */
|
|
TRY = 283, /* "try" */
|
|
CATCH = 284, /* "catch" */
|
|
LABEL = 285, /* "label" */
|
|
BREAK = 286, /* "break" */
|
|
LOC = 287, /* "$__loc__" */
|
|
SETPIPE = 288, /* "|=" */
|
|
SETPLUS = 289, /* "+=" */
|
|
SETMINUS = 290, /* "-=" */
|
|
SETMULT = 291, /* "*=" */
|
|
SETDIV = 292, /* "/=" */
|
|
SETDEFINEDOR = 293, /* "//=" */
|
|
LESSEQ = 294, /* "<=" */
|
|
GREATEREQ = 295, /* ">=" */
|
|
ALTERNATION = 296, /* "?//" */
|
|
QQSTRING_START = 297, /* QQSTRING_START */
|
|
QQSTRING_TEXT = 298, /* QQSTRING_TEXT */
|
|
QQSTRING_INTERP_START = 299, /* QQSTRING_INTERP_START */
|
|
QQSTRING_INTERP_END = 300, /* QQSTRING_INTERP_END */
|
|
QQSTRING_END = 301, /* QQSTRING_END */
|
|
FUNCDEF = 302, /* FUNCDEF */
|
|
NONOPT = 303 /* NONOPT */
|
|
};
|
|
typedef enum yytokentype yytoken_kind_t;
|
|
#endif
|
|
/* Token kinds. */
|
|
#define YYEMPTY -2
|
|
#define YYEOF 0
|
|
#define YYerror 256
|
|
#define YYUNDEF 257
|
|
#define INVALID_CHARACTER 258
|
|
#define IDENT 259
|
|
#define FIELD 260
|
|
#define BINDING 261
|
|
#define LITERAL 262
|
|
#define FORMAT 263
|
|
#define REC 264
|
|
#define SETMOD 265
|
|
#define EQ 266
|
|
#define NEQ 267
|
|
#define DEFINEDOR 268
|
|
#define AS 269
|
|
#define DEF 270
|
|
#define MODULE 271
|
|
#define IMPORT 272
|
|
#define INCLUDE 273
|
|
#define IF 274
|
|
#define THEN 275
|
|
#define ELSE 276
|
|
#define ELSE_IF 277
|
|
#define REDUCE 278
|
|
#define FOREACH 279
|
|
#define END 280
|
|
#define AND 281
|
|
#define OR 282
|
|
#define TRY 283
|
|
#define CATCH 284
|
|
#define LABEL 285
|
|
#define BREAK 286
|
|
#define LOC 287
|
|
#define SETPIPE 288
|
|
#define SETPLUS 289
|
|
#define SETMINUS 290
|
|
#define SETMULT 291
|
|
#define SETDIV 292
|
|
#define SETDEFINEDOR 293
|
|
#define LESSEQ 294
|
|
#define GREATEREQ 295
|
|
#define ALTERNATION 296
|
|
#define QQSTRING_START 297
|
|
#define QQSTRING_TEXT 298
|
|
#define QQSTRING_INTERP_START 299
|
|
#define QQSTRING_INTERP_END 300
|
|
#define QQSTRING_END 301
|
|
#define FUNCDEF 302
|
|
#define NONOPT 303
|
|
|
|
/* Value type. */
|
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
|
union YYSTYPE
|
|
{
|
|
#line 31 "src/parser.y"
|
|
|
|
jv literal;
|
|
block blk;
|
|
|
|
#line 187 "src/parser.h"
|
|
|
|
};
|
|
typedef union YYSTYPE YYSTYPE;
|
|
# 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_SRC_PARSER_H_INCLUDED */
|