summaryrefslogtreecommitdiffstats
path: root/src/parser.c
diff options
context:
space:
mode:
authorLeonid S. Usov <leonid@practi.net>2018-10-19 21:57:41 +0300
committerWilliam Langford <wlangfor@gmail.com>2019-10-22 14:11:04 -0400
commitcf4b48c7ba30cb30e116b523cff036ea481459f6 (patch)
treeb6d5a0ed3286e77d7d1fb84e8bec3c33686dd96e /src/parser.c
parentb6be13d5de6dd7d8aad5fd871eb6b0b30fc7d7f6 (diff)
Save literal value of the parsed number to preserve it for the output
Extend jv_number to use decNumber for storing number literals. Any math operations on the numbers will truncate them to double precision. Comparisons when both numbers are literal numbers will compare them without truncation. Delay conversion of numbers to doubles until a math operation is performed, to preserve precision. A literal jv_number will only need conversion to double once, and will reuse the resultant double on subsequent conversions. Outputting literal jv_numbers preserves the original precision. Add strong pthread requirement to manage contexts/allocations for converting numbers between their decNumber, string, and double formats.
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c1029
1 files changed, 522 insertions, 507 deletions
diff --git a/src/parser.c b/src/parser.c
index d9210a98..b6574e52 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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
@@ -40,11 +41,14 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.3.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -61,8 +65,8 @@
-/* Copy the first part of user declarations. */
-#line 1 "src/parser.y" /* yacc.c:339 */
+/* First part of user prologue. */
+#line 1 "src/parser.y" /* yacc.c:337 */
#include <assert.h>
#include <math.h>
@@ -73,13 +77,16 @@
#define YYMALLOC jv_mem_alloc
#define YYFREE jv_mem_free
-#line 77 "src/parser.c" /* yacc.c:339 */
-
+#line 81 "src/parser.c" /* yacc.c:337 */
# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
+# if defined __cplusplus
+# if 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
# else
-# define YY_NULLPTR 0
+# define YY_NULLPTR ((void*)0)
# endif
# endif
@@ -103,7 +110,7 @@
extern int yydebug;
#endif
/* "%code requires" blocks. */
-#line 11 "src/parser.y" /* yacc.c:355 */
+#line 11 "src/parser.y" /* yacc.c:352 */
#include "locfile.h"
struct lexer_param;
@@ -120,7 +127,7 @@ struct lexer_param;
} \
} while (0)
-#line 124 "src/parser.c" /* yacc.c:355 */
+#line 131 "src/parser.c" /* yacc.c:352 */
/* Token type. */
#ifndef YYTOKENTYPE
@@ -226,12 +233,12 @@ struct lexer_param;
union YYSTYPE
{
-#line 31 "src/parser.y" /* yacc.c:355 */
+#line 31 "src/parser.y" /* yacc.c:352 */
jv literal;
block blk;
-#line 235 "src/parser.c" /* yacc.c:355 */
+#line 242 "src/parser.c" /* yacc.c:352 */
};
typedef union YYSTYPE YYSTYPE;
@@ -259,8 +266,8 @@ int yyparse (block* answer, int* errors, struct locfile* locations, struct lexer
#endif /* !YY_YY_SRC_PARSER_H_INCLUDED */
-/* Copy the second part of user declarations. */
-#line 124 "src/parser.y" /* yacc.c:358 */
+/* Second part of user prologue. */
+#line 124 "src/parser.y" /* yacc.c:354 */
#include "lexer.h"
struct lexer_param {
@@ -312,7 +319,7 @@ static jv check_object_key(block k) {
char errbuf[15];
return jv_string_fmt("Cannot use %s (%s) as object key",
jv_kind_name(block_const_kind(k)),
- jv_dump_string_trunc(jv_copy(block_const(k)), errbuf, sizeof(errbuf)));
+ jv_dump_string_trunc(block_const(k), errbuf, sizeof(errbuf)));
}
return jv_invalid();
}
@@ -356,19 +363,25 @@ static block constant_fold(block a, block b, int op) {
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));
+ jv jv_a = block_const(a);
+ jv jv_b = block_const(b);
+
+ double na = jv_number_value(jv_a);
+ double nb = jv_number_value(jv_b);
+
+ int cmp = jv_cmp(jv_a, jv_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;
+ case EQ: res = (cmp == 0 ? jv_true() : jv_false()); break;
+ case NEQ: res = (cmp != 0 ? jv_true() : jv_false()); break;
+ case '<': res = (cmp < 0 ? jv_true() : jv_false()); break;
+ case '>': res = (cmp > 0 ? jv_true() : jv_false()); break;
+ case LESSEQ: res = (cmp <= 0 ? jv_true() : jv_false()); break;
+ case GREATEREQ: res = (cmp >= 0 ? jv_true() : jv_false()); break;
default: break;
}
} else if (op == '+' && block_const_kind(a) == JV_KIND_STRING) {
@@ -434,7 +447,7 @@ static block gen_update(block object, block val, int optype) {
}
-#line 438 "src/parser.c" /* yacc.c:358 */
+#line 451 "src/parser.c" /* yacc.c:354 */
#ifdef short
# undef short
@@ -455,13 +468,13 @@ typedef signed char yytype_int8;
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
-typedef unsigned short int yytype_uint16;
+typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
-typedef short int yytype_int16;
+typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -473,7 +486,7 @@ typedef short int yytype_int16;
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
-# define YYSIZE_T unsigned int
+# define YYSIZE_T unsigned
# endif
#endif
@@ -509,15 +522,6 @@ typedef short int yytype_int16;
# 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))
@@ -525,7 +529,7 @@ typedef short int yytype_int16;
# define YYUSE(E) /* empty */
#endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -689,16 +693,16 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES 322
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 302
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
+ as returned by yylex. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -738,23 +742,23 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 300, 300, 303, 308, 311, 322, 325, 330, 333,
- 338, 342, 345, 349, 353, 357, 360, 363, 368, 372,
- 376, 381, 388, 392, 396, 400, 404, 408, 412, 416,
- 420, 424, 428, 432, 436, 440, 444, 448, 452, 458,
- 464, 468, 472, 476, 480, 484, 488, 492, 496, 501,
- 504, 521, 530, 537, 545, 556, 561, 567, 570, 575,
- 579, 583, 590, 590, 594, 594, 601, 604, 607, 613,
- 616, 621, 624, 627, 633, 636, 639, 647, 651, 654,
- 657, 660, 663, 666, 669, 672, 675, 679, 685, 688,
- 691, 694, 697, 700, 703, 706, 709, 712, 715, 718,
- 721, 724, 727, 730, 733, 736, 739, 746, 750, 759,
- 771, 776, 777, 778, 779, 782, 785, 790, 795, 798,
- 803, 806, 811, 815, 818, 823, 826, 831, 834, 839,
- 842, 845, 848, 851, 854, 862, 868, 871, 874, 877,
- 880, 883, 886, 889, 892, 895, 898, 901, 904, 907,
- 910, 913, 916, 919, 922, 927, 930, 931, 932, 935,
- 938, 941, 944, 948, 952, 956, 960, 964, 968, 976
+ 0, 306, 306, 309, 314, 317, 328, 331, 336, 339,
+ 344, 348, 351, 355, 359, 363, 366, 369, 374, 378,
+ 382, 387, 394, 398, 402, 406, 410, 414, 418, 422,
+ 426, 430, 434, 438, 442, 446, 450, 454, 458, 464,
+ 470, 474, 478, 482, 486, 490, 494, 498, 502, 507,
+ 510, 527, 536, 543, 551, 562, 567, 573, 576, 581,
+ 585, 589, 596, 596, 600, 600, 607, 610, 613, 619,
+ 622, 627, 630, 633, 639, 642, 645, 653, 657, 660,
+ 663, 666, 669, 672, 675, 678, 681, 685, 691, 694,
+ 697, 700, 703, 706, 709, 712, 715, 718, 721, 724,
+ 727, 730, 733, 736, 739, 742, 745, 752, 756, 765,
+ 777, 782, 783, 784, 785, 788, 791, 796, 801, 804,
+ 809, 812, 817, 821, 824, 829, 832, 837, 840, 845,
+ 848, 851, 854, 857, 860, 868, 874, 877, 880, 883,
+ 886, 889, 892, 895, 898, 901, 904, 907, 910, 913,
+ 916, 919, 922, 925, 928, 933, 936, 937, 938, 941,
+ 944, 947, 950, 954, 958, 962, 966, 970, 974, 982
};
#endif
@@ -1455,22 +1459,22 @@ static const yytype_uint8 yyr2[] =
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (&yylloc, answer, errors, locations, lexer_param_ptr, YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (&yylloc, answer, errors, locations, lexer_param_ptr, YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
/* Error token number */
#define YYTERROR 1
@@ -1529,10 +1533,10 @@ do { \
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
YY_ATTRIBUTE_UNUSED
-static unsigned
+static int
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
{
- unsigned res = 0;
+ int res = 0;
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
if (0 <= yylocp->first_line)
{
@@ -1575,15 +1579,15 @@ do { \
} while (0)
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
+/*-----------------------------------.
+| Print this symbol's value on YYO. |
+`-----------------------------------*/
static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)
{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
+ FILE *yyoutput = yyo;
+ YYUSE (yyoutput);
YYUSE (yylocationp);
YYUSE (answer);
YYUSE (errors);
@@ -1593,26 +1597,26 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+ YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
+/*---------------------------.
+| Print this symbol on YYO. |
+`---------------------------*/
static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)
{
- YYFPRINTF (yyoutput, "%s %s (",
+ YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- YY_LOCATION_PRINT (yyoutput, *yylocationp);
- YYFPRINTF (yyoutput, ": ");
- yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, answer, errors, locations, lexer_param_ptr);
- YYFPRINTF (yyoutput, ")");
+ YY_LOCATION_PRINT (yyo, *yylocationp);
+ YYFPRINTF (yyo, ": ");
+ yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp, answer, errors, locations, lexer_param_ptr);
+ YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
@@ -1646,7 +1650,7 @@ do { \
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)
{
- unsigned long int yylno = yyrline[yyrule];
+ unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -1657,7 +1661,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
+ &yyvsp[(yyi + 1) - (yynrhs)]
, &(yylsp[(yyi + 1) - (yynrhs)]) , answer, errors, locations, lexer_param_ptr);
YYFPRINTF (stderr, "\n");
}
@@ -1761,7 +1765,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
- /* Fall through. */
+ else
+ goto append;
+
+ append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -1779,7 +1786,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres;
+ return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -1857,10 +1864,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
}
}
@@ -1872,6 +1879,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
case N: \
yyformat = S; \
break
+ default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -1883,9 +1891,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
if (*yymsg_alloc < yysize)
@@ -1939,193 +1948,192 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
switch (yytype)
{
- case 4: /* IDENT */
+ case 4: /* IDENT */
#line 36 "src/parser.y" /* yacc.c:1257 */
{ jv_free(((*yyvaluep).literal)); }
-#line 1946 "src/parser.c" /* yacc.c:1257 */
+#line 1955 "src/parser.c" /* yacc.c:1257 */
break;
case 5: /* FIELD */
#line 36 "src/parser.y" /* yacc.c:1257 */
{ jv_free(((*yyvaluep).literal)); }
-#line 1952 "src/parser.c" /* yacc.c:1257 */
+#line 1961 "src/parser.c" /* yacc.c:1257 */
break;
case 6: /* LITERAL */
#line 36 "src/parser.y" /* yacc.c:1257 */
{ jv_free(((*yyvaluep).literal)); }
-#line 1958 "src/parser.c" /* yacc.c:1257 */
+#line 1967 "src/parser.c" /* yacc.c:1257 */
break;
case 7: /* FORMAT */
#line 36 "src/parser.y" /* yacc.c:1257 */
{ jv_free(((*yyvaluep).literal)); }
-#line 1964 "src/parser.c" /* yacc.c:1257 */
+#line 1973 "src/parser.c" /* yacc.c:1257 */
break;
case 42: /* QQSTRING_TEXT */
#line 36 "src/parser.y" /* yacc.c:1257 */
{ jv_free(((*yyvaluep).literal)); }
-#line 1970 "src/parser.c" /* yacc.c:1257 */
+#line 1979 "src/parser.c" /* yacc.c:1257 */
break;
case 71: /* Module */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 1976 "src/parser.c" /* yacc.c:1257 */
+#line 1985 "src/parser.c" /* yacc.c:1257 */
break;
case 72: /* Imports */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 1982 "src/parser.c" /* yacc.c:1257 */
+#line 1991 "src/parser.c" /* yacc.c:1257 */
break;
case 73: /* FuncDefs */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 1988 "src/parser.c" /* yacc.c:1257 */
+#line 1997 "src/parser.c" /* yacc.c:1257 */
break;
case 74: /* Exp */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 1994 "src/parser.c" /* yacc.c:1257 */
+#line 2003 "src/parser.c" /* yacc.c:1257 */
break;
case 75: /* Import */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2000 "src/parser.c" /* yacc.c:1257 */
+#line 2009 "src/parser.c" /* yacc.c:1257 */
break;
case 76: /* ImportWhat */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2006 "src/parser.c" /* yacc.c:1257 */
+#line 2015 "src/parser.c" /* yacc.c:1257 */
break;
case 77: /* ImportFrom */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2012 "src/parser.c" /* yacc.c:1257 */
+#line 2021 "src/parser.c" /* yacc.c:1257 */
break;
case 78: /* FuncDef */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2018 "src/parser.c" /* yacc.c:1257 */
+#line 2027 "src/parser.c" /* yacc.c:1257 */
break;
case 79: /* Params */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2024 "src/parser.c" /* yacc.c:1257 */
+#line 2033 "src/parser.c" /* yacc.c:1257 */
break;
case 80: /* Param */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2030 "src/parser.c" /* yacc.c:1257 */
+#line 2039 "src/parser.c" /* yacc.c:1257 */
break;
case 81: /* String */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2036 "src/parser.c" /* yacc.c:1257 */
+#line 2045 "src/parser.c" /* yacc.c:1257 */
break;
case 84: /* QQString */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2042 "src/parser.c" /* yacc.c:1257 */
+#line 2051 "src/parser.c" /* yacc.c:1257 */
break;
case 85: /* ElseBody */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2048 "src/parser.c" /* yacc.c:1257 */
+#line 2057 "src/parser.c" /* yacc.c:1257 */
break;
case 86: /* ExpD */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2054 "src/parser.c" /* yacc.c:1257 */
+#line 2063 "src/parser.c" /* yacc.c:1257 */
break;
case 87: /* Term */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2060 "src/parser.c" /* yacc.c:1257 */
+#line 2069 "src/parser.c" /* yacc.c:1257 */
break;
case 88: /* Args */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2066 "src/parser.c" /* yacc.c:1257 */
+#line 2075 "src/parser.c" /* yacc.c:1257 */
break;
case 89: /* Arg */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2072 "src/parser.c" /* yacc.c:1257 */
+#line 2081 "src/parser.c" /* yacc.c:1257 */
break;
case 90: /* RepPatterns */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2078 "src/parser.c" /* yacc.c:1257 */
+#line 2087 "src/parser.c" /* yacc.c:1257 */
break;
case 91: /* Patterns */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2084 "src/parser.c" /* yacc.c:1257 */
+#line 2093 "src/parser.c" /* yacc.c:1257 */
break;
case 92: /* Pattern */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2090 "src/parser.c" /* yacc.c:1257 */
+#line 2099 "src/parser.c" /* yacc.c:1257 */
break;
case 93: /* ArrayPats */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2096 "src/parser.c" /* yacc.c:1257 */
+#line 2105 "src/parser.c" /* yacc.c:1257 */
break;
case 94: /* ObjPats */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2102 "src/parser.c" /* yacc.c:1257 */
+#line 2111 "src/parser.c" /* yacc.c:1257 */
break;
case 95: /* ObjPat */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2108 "src/parser.c" /* yacc.c:1257 */
+#line 2117 "src/parser.c" /* yacc.c:1257 */
break;
case 96: /* Keyword */
#line 36 "src/parser.y" /* yacc.c:1257 */
{ jv_free(((*yyvaluep).literal)); }
-#line 2114 "src/parser.c" /* yacc.c:1257 */
+#line 2123 "src/parser.c" /* yacc.c:1257 */
break;
case 97: /* MkDict */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2120 "src/parser.c" /* yacc.c:1257 */
+#line 2129 "src/parser.c" /* yacc.c:1257 */
break;
case 98: /* MkDictPair */
#line 37 "src/parser.y" /* yacc.c:1257 */
{ block_free(((*yyvaluep).blk)); }
-#line 2126 "src/parser.c" /* yacc.c:1257 */
+#line 2135 "src/parser.c" /* yacc.c:1257 */
break;
-
default:
break;
}
@@ -2231,23 +2239,31 @@ YYLTYPE yylloc = yyloc_default;
yylsp[0] = yylloc;
goto yysetstate;
+
/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
+| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
- yynewstate:
+yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
- yysetstate:
- *yyssp = yystate;
+
+/*--------------------------------------------------------------------.
+| yynewstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
+ *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+#else
{
/* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
+ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow
+# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
@@ -2265,15 +2281,11 @@ YYLTYPE yylloc = yyloc_default;
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
-
- yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
+ yyls = yyls1;
}
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
@@ -2290,23 +2302,23 @@ YYLTYPE yylloc = yyloc_default;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
YYSTACK_RELOCATE (yyls_alloc, yyls);
-# undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
-#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
yylsp = yyls + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -2315,11 +2327,11 @@ YYLTYPE yylloc = yyloc_default;
goto yybackup;
+
/*-----------.
| yybackup. |
`-----------*/
yybackup:
-
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -2392,7 +2404,7 @@ yydefault:
/*-----------------------------.
-| yyreduce -- Do a reduction. |
+| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -2408,37 +2420,38 @@ yyreduce:
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
- /* Default location. */
+ /* Default location. */
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
+ yyerror_range[1] = yyloc;
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
-#line 300 "src/parser.y" /* yacc.c:1646 */
+#line 306 "src/parser.y" /* yacc.c:1667 */
{
*answer = BLOCK((yyvsp[-2].blk), (yyvsp[-1].blk), gen_op_simple(TOP), (yyvsp[0].blk));
}
-#line 2422 "src/parser.c" /* yacc.c:1646 */
+#line 2435 "src/parser.c" /* yacc.c:1667 */
break;
case 3:
-#line 303 "src/parser.y" /* yacc.c:1646 */
+#line 309 "src/parser.y" /* yacc.c:1667 */
{
*answer = BLOCK((yyvsp[-2].blk), (yyvsp[-1].blk), (yyvsp[0].blk));
}
-#line 2430 "src/parser.c" /* yacc.c:1646 */
+#line 2443 "src/parser.c" /* yacc.c:1667 */
break;
case 4:
-#line 308 "src/parser.y" /* yacc.c:1646 */
+#line 314 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_noop();
}
-#line 2438 "src/parser.c" /* yacc.c:1646 */
+#line 2451 "src/parser.c" /* yacc.c:1667 */
break;
case 5:
-#line 311 "src/parser.y" /* yacc.c:1646 */
+#line 317 "src/parser.y" /* yacc.c:1667 */
{
if (!block_is_const((yyvsp[-1].blk))) {
FAIL((yyloc), "Module metadata must be constant");
@@ -2448,374 +2461,374 @@ yyreduce:
(yyval.blk) = gen_module((yyvsp[-1].blk));
}
}
-#line 2452 "src/parser.c" /* yacc.c:1646 */
+#line 2465 "src/parser.c" /* yacc.c:1667 */
break;
case 6:
-#line 322 "src/parser.y" /* yacc.c:1646 */
+#line 328 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_noop();
}
-#line 2460 "src/parser.c" /* yacc.c:1646 */
+#line 2473 "src/parser.c" /* yacc.c:1667 */
break;
case 7:
-#line 325 "src/parser.y" /* yacc.c:1646 */
+#line 331 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = BLOCK((yyvsp[-1].blk), (yyvsp[0].blk));
}
-#line 2468 "src/parser.c" /* yacc.c:1646 */
+#line 2481 "src/parser.c" /* yacc.c:1667 */
break;
case 8:
-#line 330 "src/parser.y" /* yacc.c:1646 */
+#line 336 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_noop();
}
-#line 2476 "src/parser.c" /* yacc.c:1646 */
+#line 2489 "src/parser.c" /* yacc.c:1667 */
break;
case 9:
-#line 333 "src/parser.y" /* yacc.c:1646 */
+#line 339 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = block_join((yyvsp[-1].blk), (yyvsp[0].blk));
}
-#line 2484 "src/parser.c" /* yacc.c:1646 */
+#line 2497 "src/parser.c" /* yacc.c:1667 */
break;
case 10:
-#line 338 "src/parser.y" /* yacc.c:1646 */
+#line 344 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = block_bind_referenced((yyvsp[-1].blk), (yyvsp[0].blk), OP_IS_CALL_PSEUDO);
}
-#line 2492 "src/parser.c" /* yacc.c:1646 */
+#line 2505 "src/parser.c" /* yacc.c:1667 */
break;
case 11:
-#line 342 "src/parser.y" /* yacc.c:1646 */
+#line 348 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_destructure((yyvsp[-4].blk), (yyvsp[-2].blk), (yyvsp[0].blk));
}
-#line 2500 "src/parser.c" /* yacc.c:1646 */
+#line 2513 "src/parser.c" /* yacc.c:1667 */
break;
case 12:
-#line 345 "src/parser.y" /* yacc.c:1646 */
+#line 351 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_reduce((yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk));
}
-#line 2508 "src/parser.c" /* yacc.c:1646 */
+#line 2521 "src/parser.c" /* yacc.c:1667 */
break;
case 13:
-#line 349 "src/parser.y" /* yacc.c:1646 */
+#line 355 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_foreach((yyvsp[-9].blk), (yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk));
}
-#line 2516 "src/parser.c" /* yacc.c:1646 */
+#line 2529 "src/parser.c" /* yacc.c:1667 */
break;
case 14:
-#line 353 "src/parser.y" /* yacc.c:1646 */
+#line 359 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_foreach((yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk), gen_noop());
}
-#line 2524 "src/parser.c" /* yacc.c:1646 */
+#line 2537 "src/parser.c" /* yacc.c:1667 */
break;
case 15:
-#line 357 "src/parser.y" /* yacc.c:1646 */
+#line 363 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_cond((yyvsp[-3].blk), (yyvsp[-1].blk), (yyvsp[0].blk));
}
-#line 2532 "src/parser.c" /* yacc.c:1646 */
+#line 2545 "src/parser.c" /* yacc.c:1667 */
break;
case 16:
-#line 360 "src/parser.y" /* yacc.c:1646 */
+#line 366 "src/parser.y" /* yacc.c:1667 */
{
(yyval.blk) = gen_cond((yyvsp[-3].blk), (yyvsp[-1].blk), gen_noop());
}
-#line 2540 "src/parser.c" /* yacc.c:1646 */
+#line 2553 "src/parser.c" /* yacc.c:1667 */
break;
case 17:
-#line 363 "src/parser.y" /* yacc.c:1646 */
+#line 369 "src/parser.y" /* yacc.c:1667 */
{
FAIL((yyloc), "Possibly unterminated 'if' statement");
(yyval.blk) = (yyvsp[-2].blk);
}
-#line 2549 "src/parser.c" /* yacc.c:1646 */
+#line 2562 "src/parser.c" /* yacc.c:1667 */
break;
case 18:
-#line 368 "src/parser.y" /* yacc.c:1646 */
+#line 374 "src/parser.y" /* yacc.c:1667 */
{
//$$ = BLOCK(gen_op_target(FORK_OPT, $2), $2, $4);
(yyval.blk) = gen_try((yyvsp[-2].blk), gen_try_handler((yyvsp[0].blk)));
}
-#line 2558 "src/parser.c" /* yacc.c:1646 */
+#line 2571 "src/parser.c" /* yacc.c:1667 */
break;
case 19:
-#line 372 "src/parser.y" /* yacc.c:1646 */
+#line 378 "src/parser.y" /* yacc.c:1667 */
{
//$$ = BLOCK(gen_op_target(FORK_OPT, $2), $2, gen_op_simple(BACKTRACK));
(yyval.blk) = gen_try((yyvsp[0].blk), gen_op_simple(BACKTRACK));
}
-#line 2567 "src/parser.c" /* yacc.c:1646 */
+#line 2580 "src/parser.c" /* yacc.c:1667 */
break;
case 20:
-#line 376 "src/parser.y" /* yacc.c:1646 */
+#line 382 "src/parser.y" /* yacc.c:1667 */
{
FAIL((yyloc), "Possibly unterminated 'try' statement");
(yyval.blk) = (yyvsp[-2].blk);
}
-#line 2576 "src/parser.c" /* yacc.c:1646 */
+#line 2589 "src/parser.c" /* yacc.c:1667 */
break;
case 21:
-#line 381 "src/parser.y" /* yacc.c:1646 */
+#line 387 "src/parser.y" /* yacc.c:1667 */
{
jv v = jv_string_fmt("*label-%s", jv_string_value((yyvsp[-2].literal)));
(yyval.blk) = gen_location((yyloc), locations, gen_label(jv_string_value(v), (