From 568fac7335b1873f5c7cc49655b696cfb9acac92 Mon Sep 17 00:00:00 2001
From: Alex Rozenmane
Date: Sun, 29 Mar 2009 23:48:56 +0300
Subject: [PATCH] 2009-03-29 Alex Rozenman
Implement support for named symbol references.
* src/parse-gram.y: Add new syntax (named_ref.opt).
* src/reader.c: Store named refs in symbol lists.
* src/reader.h: New argument for symbol_append and
action_append functions.
* src/scan-code.h: Add new field (named_ref) into
code_props data structure. Keeps named ref of midrule
actions.
* src/scan-code.l: Support for named refs in semantic
action code. New function 'parse_named_ref'.
* src/scan-gram.l: Support bracketed id.
* src/symlist.c: Store named refs in symbol lists.
* src/symlist.h: New field in symbol list: named_ref.
* src/named-ref.h: New file, a struct for named_ref.
* src/named-ref.cp: New file, named_ref_new function.
* src/local.mk: Add two new files.
* src/parse-gram.h, src/parse-gram.c: Regen.
* tests/testsuite.at: Include new test group:
* tests/named-refs.at: this new file.
---
ChangeLog | 23 +
src/local.mk | 4 +-
src/named-ref.c | 41 ++
src/named-ref.h | 38 ++
src/parse-gram.c | 1506 +++++++++++++++++++++++----------------------------
src/parse-gram.h | 19 +-
src/parse-gram.y | 29 +-
src/reader.c | 56 ++-
src/reader.h | 7 +-
src/scan-code.h | 9 +-
src/scan-code.l | 384 +++++++++++--
src/scan-gram.l | 78 +++-
src/symlist.c | 13 +-
src/symlist.h | 7 +
tests/named-refs.at | 269 +++++++++
tests/testsuite.at | 5 +
16 files changed, 1557 insertions(+), 931 deletions(-)
create mode 100644 src/named-ref.c
create mode 100644 src/named-ref.h
create mode 100644 tests/named-refs.at
diff --git a/ChangeLog b/ChangeLog
index 2f687c2..3f079c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2009-03-29 Alex Rozenman
+
+ Implement support for named symbol references.
+
+ * src/parse-gram.y: Add new syntax (named_ref.opt).
+ * src/reader.c: Store named refs in symbol lists.
+ * src/reader.h: New argument for symbol_append and
+ action_append functions.
+ * src/scan-code.h: Add new field (named_ref) into
+ code_props data structure. Keeps named ref of midrule
+ actions.
+ * src/scan-code.l: Support for named refs in semantic
+ action code. New function 'parse_named_ref'.
+ * src/scan-gram.l: Support bracketed id.
+ * src/symlist.c: Store named refs in symbol lists.
+ * src/symlist.h: New field in symbol list: named_ref.
+ * src/named-ref.h: New file, a struct for named_ref.
+ * src/named-ref.cp: New file, named_ref_new function.
+ * src/local.mk: Add two new files.
+ * src/parse-gram.h, src/parse-gram.c: Regen.
+ * tests/testsuite.at: Include new test group:
+ * tests/named-refs.at: this new file.
+
2009-03-26 Akim Demaille
doc: merge HACKING and README-hacking.
diff --git a/src/local.mk b/src/local.mk
index 6d94330..6832281 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -94,7 +94,9 @@ src_bison_SOURCES = \
src/tables.c \
src/tables.h \
src/uniqstr.c \
- src/uniqstr.h
+ src/uniqstr.h \
+ src/named-ref.c \
+ src/named-ref.h
EXTRA_src_bison_SOURCES = \
src/scan-code.l \
diff --git a/src/named-ref.c b/src/named-ref.c
new file mode 100644
index 0000000..d727250
--- /dev/null
+++ b/src/named-ref.c
@@ -0,0 +1,41 @@
+/* Named symbol references for Bison
+
+ Copyright 2000 Free Software Foundation, Inc.
+
+ This file is part of Bison, the GNU Compiler Compiler.
+
+ 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 . */
+
+#include
+#include "system.h"
+
+#include "named-ref.h"
+
+named_ref *
+named_ref_new (uniqstr id, location loc)
+{
+ named_ref *res = xmalloc (sizeof *res);
+
+ res->id = id;
+ res->loc = loc;
+
+ return res;
+}
+
+void
+named_ref_free (named_ref *r)
+{
+ free (r);
+}
+
diff --git a/src/named-ref.h b/src/named-ref.h
new file mode 100644
index 0000000..eb63d7b
--- /dev/null
+++ b/src/named-ref.h
@@ -0,0 +1,38 @@
+/* Named symbol references for Bison
+
+ Copyright 2000 Free Software Foundation, Inc.
+
+ This file is part of Bison, the GNU Compiler Compiler.
+
+ 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 . */
+
+#ifndef NAMED_REF_H_
+# define NAMED_REF_H_
+
+#include "uniqstr.h"
+#include "location.h"
+
+typedef struct named_ref named_ref;
+
+struct named_ref
+{
+ uniqstr id;
+ location loc;
+};
+
+named_ref *named_ref_new (uniqstr id, location loc);
+
+void named_ref_free (named_ref *r);
+
+#endif /* !NAMED_REF_H_ */
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 88181c6..cad5640 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.4.194-c20a1-dirty. */
+/* A Bison parser, made by GNU Bison 2.4.259-91be6-dirty. */
/* Implementation for Bison's Yacc-like parsers in C
@@ -45,7 +45,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.4.194-c20a1-dirty"
+#define YYBISON_VERSION "2.4.259-91be6-dirty"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -73,7 +73,6 @@
#define yylloc gram_lloc
/* Copy the first part of user declarations. */
-
/* Line 191 of yacc.c */
#line 1 "parse-gram.y"
/* Bison Grammar Parser -*- C -*-
@@ -108,6 +107,7 @@
#include "quotearg.h"
#include "reader.h"
#include "symlist.h"
+#include "named-ref.h"
#include "scan-gram.h"
#include "scan-code.h"
@@ -141,6 +141,7 @@ static symbol_class current_class = unknown_sym;
static uniqstr current_type = NULL;
static symbol *current_lhs;
static location current_lhs_location;
+static named_ref *current_lhs_named_ref;
static int current_prec = 0;
#define YYTYPE_INT16 int_fast16_t
@@ -148,9 +149,8 @@ static int current_prec = 0;
#define YYTYPE_UINT16 uint_fast16_t
#define YYTYPE_UINT8 uint_fast8_t
-
/* Line 191 of yacc.c */
-#line 154 "../../src/parse-gram.c"
+#line 154 "../bison/src/parse-gram.c"
/* Enabling traces. */
#ifndef YYDEBUG
@@ -232,7 +232,8 @@ static int current_prec = 0;
TAG = 309,
TAG_ANY = 310,
TAG_NONE = 311,
- PERCENT_UNION = 312
+ BRACKETED_ID = 312,
+ PERCENT_UNION = 313
};
#endif
/* Tokens. */
@@ -291,7 +292,8 @@ static int current_prec = 0;
#define TAG 309
#define TAG_ANY 310
#define TAG_NONE 311
-#define PERCENT_UNION 312
+#define BRACKETED_ID 312
+#define PERCENT_UNION 313
@@ -299,9 +301,8 @@ static int current_prec = 0;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
-
/* Line 216 of yacc.c */
-#line 92 "parse-gram.y"
+#line 94 "parse-gram.y"
symbol *symbol;
symbol_list *list;
@@ -311,11 +312,11 @@ typedef union YYSTYPE
assoc assoc;
uniqstr uniqstr;
unsigned char character;
-
+ named_ref *named_ref;
/* Line 216 of yacc.c */
-#line 319 "../../src/parse-gram.c"
+#line 320 "../bison/src/parse-gram.c"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -338,9 +339,8 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
-
/* Line 266 of yacc.c */
-#line 344 "../../src/parse-gram.c"
+#line 344 "../bison/src/parse-gram.c"
#ifdef short
# undef short
@@ -557,21 +557,21 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 3
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 203
+#define YYLAST 202
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 58
+#define YYNTOKENS 59
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 33
+#define YYNNTS 34
/* YYNRULES -- Number of rules. */
-#define YYNRULES 106
+#define YYNRULES 108
/* YYNSTATES -- Number of states. */
-#define YYNSTATES 144
+#define YYNSTATES 148
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 312
+#define YYMAXUTOK 313
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -611,24 +611,24 @@ static const yytype_uint8 yytranslate[] =
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57
+ 55, 56, 57, 58
};
#if YYDEBUG
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+ /* YYRLINEYYN -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 203, 203, 211, 213, 217, 218, 228, 229, 233,
- 234, 239, 240, 241, 242, 243, 244, 249, 258, 259,
- 260, 261, 262, 263, 264, 265, 266, 267, 268, 281,
- 282, 306, 307, 308, 309, 313, 314, 315, 319, 326,
- 333, 337, 341, 348, 363, 364, 368, 380, 380, 385,
- 385, 390, 401, 416, 417, 418, 419, 423, 424, 429,
- 431, 436, 437, 442, 444, 449, 450, 454, 455, 456,
- 457, 462, 467, 472, 478, 484, 495, 496, 505, 506,
- 512, 513, 514, 521, 521, 525, 526, 527, 532, 533,
- 535, 537, 539, 541, 551, 552, 558, 561, 570, 590,
- 592, 601, 606, 607, 612, 619, 621
+ 0, 208, 208, 216, 218, 222, 223, 233, 234, 238,
+ 239, 244, 245, 246, 247, 248, 249, 254, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 286,
+ 287, 311, 312, 313, 314, 318, 319, 320, 324, 331,
+ 338, 342, 346, 353, 368, 369, 373, 385, 385, 390,
+ 390, 395, 406, 421, 422, 423, 424, 428, 429, 434,
+ 436, 441, 442, 447, 449, 454, 455, 459, 460, 461,
+ 462, 467, 472, 477, 483, 489, 500, 501, 510, 511,
+ 517, 518, 519, 526, 526, 531, 532, 533, 538, 540,
+ 542, 544, 546, 548, 554, 556, 566, 567, 573, 576,
+ 585, 605, 607, 616, 621, 622, 627, 634, 636
};
#endif
@@ -650,15 +650,15 @@ static const char *const yytname[] =
"\"%skeleton\"", "\"%start\"", "\"%token-table\"", "\"%verbose\"",
"\"%yacc\"", "\"{...}\"", "\"char\"", "\"epilogue\"", "\"=\"",
"\"identifier\"", "\"identifier:\"", "\"%%\"", "\"|\"", "\"%{...%}\"",
- "\";\"", "\"\"", "\"<*>\"", "\"<>\"", "\"%union\"", "$accept",
- "input", "prologue_declarations", "prologue_declaration",
+ "\";\"", "\"\"", "\"<*>\"", "\"<>\"", "\"[id]\"", "\"%union\"",
+ "$accept", "input", "prologue_declarations", "prologue_declaration",
"grammar_declaration", "union_name", "symbol_declaration", "address@hidden", "address@hidden",
"precedence_declaration", "precedence_declarator", "tag.opt",
"symbols.prec", "symbol.prec", "symbols.1", "generic_symlist",
"generic_symlist_item", "symbol_def", "symbol_defs.1", "grammar",
"rules_or_grammar_declaration", "rules", "address@hidden", "rhses.1", "rhs",
- "variable", "content.opt", "braceless", "id", "id_colon", "symbol",
- "string_as_id", "epilogue.opt", 0
+ "named_ref.opt", "variable", "content.opt", "braceless", "id",
+ "id_colon", "symbol", "string_as_id", "epilogue.opt", 0
};
#endif
@@ -672,33 +672,33 @@ static const yytype_uint16 yytoknum[] =
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, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312
+ 305, 306, 307, 308, 309, 310, 311, 312, 313
};
# endif
-#define YYPACT_NINF -81
+#define YYPACT_NINF -98
-#define YYTABLE_NINF -106
+#define YYTABLE_NINF -108
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int16 yypact[] =
{
- -81, 23, 111, -81, -81, -81, -28, -12, -8, -81,
- -81, -81, -81, -13, -81, -81, 14, 43, -81, 48,
- 49, 2, -81, 10, 53, 34, -81, 13, -81, -81,
- -81, 26, 36, -81, 54, 78, 0, -81, -81, -81,
- 58, -81, -81, 41, -81, -81, -81, -81, 28, -24,
- -24, 0, 31, 31, -81, 44, -81, -81, -81, 81,
- -81, -81, -81, -81, 88, -81, -81, -81, -81, 89,
- -81, 91, -81, -81, -81, -81, -81, -81, -81, -81,
- -81, 42, -81, 47, 1, -81, -81, -81, -81, 44,
- -81, 0, -81, -81, -24, 40, -24, 0, -81, -81,
- -81, -81, 31, -81, -81, 31, -81, -81, -81, -81,
- -81, -81, -81, -81, 50, -81, -81, -81, -81, 0,
- -81, 93, -81, 98, -81, -81, -81, -81, -14, 155,
- -81, -81, -81, -81, -81, 0, 99, 51, -81, -81,
- 155, -81, -81, -81
+ -98, 34, 113, -98, -98, -98, -38, 3, 9, -98,
+ -98, -98, -98, -12, -98, -98, 14, 43, -98, 50,
+ 52, 2, -98, 13, 55, 35, -98, 16, -98, -98,
+ -98, 27, 37, -98, 79, 80, 0, -98, -98, -98,
+ 59, -98, -98, 41, -98, -98, -98, -98, 31, -23,
+ -23, 0, 32, 32, -98, 46, -98, -98, -98, 89,
+ -98, -98, -98, -98, 90, -98, -98, -98, -98, 91,
+ -98, 92, -98, -98, -98, -98, -98, -98, -98, -98,
+ -98, 44, -98, 47, 1, -98, -98, 39, -98, 46,
+ -98, 0, -98, -98, -23, 23, -23, 0, -98, -98,
+ -98, -98, 32, -98, -98, 32, -98, -98, -98, -98,
+ -98, -98, -98, -98, 56, -98, -98, -98, -98, -98,
+ 0, -98, 99, -98, 101, -98, -98, -98, -98, -98,
+ -98, -98, -98, -14, 154, -98, -98, 0, 103, 51,
+ 39, 39, 154, -98, -98, -98, -98, -98
};
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
@@ -711,34 +711,34 @@ static const yytype_uint8 yydefact[] =
0, 0, 16, 0, 0, 0, 20, 0, 41, 23,
24, 0, 0, 28, 0, 0, 0, 31, 32, 33,
0, 6, 34, 44, 4, 5, 36, 35, 57, 0,
- 0, 0, 0, 0, 98, 0, 42, 95, 94, 96,
+ 0, 0, 0, 0, 100, 0, 42, 97, 96, 98,
10, 12, 13, 14, 0, 17, 18, 19, 21, 0,
- 25, 0, 27, 29, 30, 104, 100, 99, 102, 37,
- 103, 0, 101, 0, 0, 78, 80, 83, 45, 0,
+ 25, 0, 27, 29, 30, 106, 102, 101, 104, 37,
+ 105, 0, 103, 0, 0, 78, 80, 94, 45, 0,
58, 0, 71, 76, 50, 72, 48, 51, 63, 68,
- 69, 70, 38, 65, 67, 39, 43, 97, 8, 15,
- 22, 26, 82, 81, 0, 79, 2, 88, 46, 52,
- 59, 61, 77, 73, 74, 64, 66, 106, 84, 85,
- 60, 62, 75, 88, 87, 0, 0, 0, 90, 89,
- 86, 91, 92, 93
+ 69, 70, 38, 65, 67, 39, 43, 99, 8, 15,
+ 22, 26, 82, 81, 0, 79, 2, 95, 83, 46,
+ 52, 59, 61, 77, 73, 74, 64, 66, 108, 88,
+ 60, 62, 75, 84, 85, 88, 87, 0, 0, 0,
+ 94, 94, 86, 91, 92, 93, 90, 89
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -81, -81, -81, -81, 100, -81, -81, -81, -81, -81,
- -81, -81, -81, -11, -81, 56, -80, -54, 60, -81,
- 22, -81, -81, -81, -21, -81, -81, -51, -22, -81,
- -36, -76, -81
+ -98, -98, -98, -98, 107, -98, -98, -98, -98, -98,
+ -98, -98, -98, -10, -98, 58, -81, -54, 62, -98,
+ 29, -98, -98, -98, -20, -97, -98, -98, -51, -21,
+ -98, -36, -72, -98
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
-1, 1, 2, 44, 83, 89, 46, 50, 49, 47,
- 48, 91, 119, 120, 97, 102, 103, 93, 94, 84,
- 85, 86, 117, 128, 129, 59, 108, 56, 78, 87,
- 104, 80, 116
+ 48, 91, 120, 121, 97, 102, 103, 93, 94, 84,
+ 85, 86, 129, 133, 134, 118, 59, 108, 56, 78,
+ 87, 104, 80, 116
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@@ -747,89 +747,89 @@ static const yytype_int16 yydefgoto[] =
If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
- 79, -105, 81, 75, 106, 63, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 98, 68, 57, 13, 124,
- 15, 76, 126, 3, 77, 126, 51, 95, 95, 70,
- 92, 54, 52, 28, 75, 55, 53, 133, 118, 134,
- 122, 36, 122, 75, 123, 76, 60, 132, 77, 64,
- 82, 114, 61, 62, 65, 121, 66, 73, 43, 81,
- 69, 125, 58, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 95, 71, 95, 13, 76, 15, 67, 77,
- 72, 74, 90, 121, 107, 99, 100, 101, 54, 88,
- 28, 109, 110, 139, 111, 112, 127, 131, 36, 141,
- 113, 75, 45, 142, 139, 143, 115, 82, 130, 105,
- 96, 0, 140, 0, 0, 43, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 0, 0, 0, 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, 0, 0, 0, 75, 0,
- 0, 40, 0, 41, 42, 0, 0, 0, 43, 135,
- 136, 137, 0, 0, 0, 0, 0, 0, 0, 0,
+ 79, -107, 81, 75, 106, 63, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 98, 51, 57, 13, 68,
+ 15, 127, 76, 125, 127, 77, 75, 124, 95, 95,
+ 70, 92, 54, 28, 3, 75, 55, 135, 119, 136,
+ 123, 36, 123, 146, 147, 76, 60, 52, 77, 64,
+ 82, 114, 132, 53, 61, 122, 62, 65, 66, 43,
+ 81, 126, 58, 69, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 95, 71, 95, 13, 76, 15, 67,
+ 77, 72, 73, 74, 122, 90, 99, 100, 101, 88,
+ 54, 28, 107, 109, 110, 111, 117, 112, 141, 36,
+ 113, 143, 128, 131, 75, 145, 141, 144, 82, 45,
+ 130, 105, 96, 115, 0, 142, 0, 43, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 0, 0, 0,
+ 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, 75, 0, 0,
+ 0, 0, 0, 40, 0, 41, 42, 0, 137, 138,
+ 139, 43, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 138,
- 76, 0, 0, 77
+ 0, 0, 0, 0, 0, 0, 0, 0, 140, 76,
+ 0, 0, 77
};
static const yytype_int16 yycheck[] =
{
36, 0, 1, 3, 55, 3, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 51, 3, 3, 17, 95,
- 19, 45, 102, 0, 48, 105, 54, 49, 50, 3,
- 54, 44, 44, 32, 3, 48, 44, 51, 89, 53,
- 94, 40, 96, 3, 4, 45, 3, 123, 48, 47,
- 49, 50, 4, 4, 44, 91, 3, 3, 57, 1,
- 47, 97, 48, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 94, 47, 96, 17, 45, 19, 44, 48,
- 44, 3, 54, 119, 3, 54, 55, 56, 44, 48,
- 32, 3, 3, 129, 3, 53, 46, 4, 40, 135,
- 53, 3, 2, 4, 140, 54, 84, 49, 119, 53,
- 50, -1, 133, -1, -1, 57, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, -1, -1, -1, 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, -1, -1, -1, 3, -1,
- -1, 50, -1, 52, 53, -1, -1, -1, 57, 14,
- 15, 16, -1, -1, -1, -1, -1, -1, -1, -1,
+ 9, 10, 11, 12, 13, 51, 54, 3, 17, 3,
+ 19, 102, 45, 95, 105, 48, 3, 4, 49, 50,
+ 3, 54, 44, 32, 0, 3, 48, 51, 89, 53,
+ 94, 40, 96, 140, 141, 45, 3, 44, 48, 47,
+ 49, 50, 124, 44, 4, 91, 4, 44, 3, 58,
+ 1, 97, 48, 47, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 94, 47, 96, 17, 45, 19, 44,
+ 48, 44, 3, 3, 120, 54, 54, 55, 56, 48,
+ 44, 32, 3, 3, 3, 3, 57, 53, 134, 40,
+ 53, 137, 46, 4, 3, 54, 142, 4, 49, 2,
+ 120, 53, 50, 84, -1, 135, -1, 58, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, -1, -1, -1,
+ 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, 3, -1, -1,
+ -1, -1, -1, 50, -1, 52, 53, -1, 14, 15,
+ 16, 58, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 44,
- 45, -1, -1, 48
+ -1, -1, -1, -1, -1, -1, -1, -1, 44, 45,
+ -1, -1, 48
};
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 59, 60, 0, 5, 6, 7, 8, 9, 10,
+ 0, 60, 61, 0, 5, 6, 7, 8, 9, 10,
11, 12, 13, 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,
- 50, 52, 53, 57, 61, 62, 64, 67, 68, 66,
- 65, 54, 44, 44, 44, 48, 85, 3, 48, 83,
+ 50, 52, 53, 58, 62, 63, 65, 68, 69, 67,
+ 66, 54, 44, 44, 44, 48, 87, 3, 48, 85,
3, 4, 4, 3, 47, 44, 3, 44, 3, 47,
- 3, 47, 44, 3, 3, 3, 45, 48, 86, 88,
- 89, 1, 49, 62, 77, 78, 79, 87, 48, 63,
- 54, 69, 54, 75, 76, 86, 76, 72, 88, 54,
- 55, 56, 73, 74, 88, 73, 85, 3, 84, 3,
- 3, 3, 53, 53, 50, 78, 90, 80, 85, 70,
- 71, 88, 75, 4, 89, 88, 74, 46, 81, 82,
- 71, 4, 89, 51, 53, 14, 15, 16, 44, 88,
- 82, 88, 4, 54
+ 3, 47, 44, 3, 3, 3, 45, 48, 88, 90,
+ 91, 1, 49, 63, 78, 79, 80, 89, 48, 64,
+ 54, 70, 54, 76, 77, 88, 77, 73, 90, 54,
+ 55, 56, 74, 75, 90, 74, 87, 3, 86, 3,
+ 3, 3, 53, 53, 50, 79, 92, 57, 84, 87,
+ 71, 72, 90, 76, 4, 91, 90, 75, 46, 81,
+ 72, 4, 91, 82, 83, 51, 53, 14, 15, 16,
+ 44, 90, 83, 90, 4, 54, 84, 84
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
- 0, 58, 59, 60, 60, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 63, 63, 62, 65, 64, 66,
- 64, 64, 67, 68, 68, 68, 68, 69, 69, 70,
- 70, 71, 71, 72, 72, 73, 73, 74, 74, 74,
- 74, 75, 75, 75, 75, 75, 76, 76, 77, 77,
- 78, 78, 78, 80, 79, 81, 81, 81, 82, 82,
- 82, 82, 82, 82, 83, 83, 84, 84, 85, 86,
- 86, 87, 88, 88, 89, 90, 90
+ 0, 59, 60, 61, 61, 62, 62, 62, 62, 62,
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
+ 62, 62, 62, 62, 62, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 64, 64, 63, 66, 65, 67,
+ 65, 65, 68, 69, 69, 69, 69, 70, 70, 71,
+ 71, 72, 72, 73, 73, 74, 74, 75, 75, 75,
+ 75, 76, 76, 76, 76, 76, 77, 77, 78, 78,
+ 79, 79, 79, 81, 80, 82, 82, 82, 83, 83,
+ 83, 83, 83, 83, 84, 84, 85, 85, 86, 86,
+ 87, 88, 88, 89, 90, 90, 91, 92, 92
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@@ -843,9 +843,9 @@ static const yytype_uint8 yyr2[] =
3, 3, 3, 1, 1, 1, 1, 0, 1, 1,
2, 1, 2, 1, 2, 1, 2, 1, 1, 1,
1, 1, 1, 2, 2, 3, 1, 2, 1, 2,
- 1, 2, 2, 0, 3, 1, 3, 2, 0, 2,
- 2, 3, 3, 3, 1, 1, 0, 1, 1, 1,
- 1, 1, 1, 1, 1, 0, 2
+ 1, 2, 2, 0, 4, 1, 3, 2, 0, 3,
+ 3, 3, 3, 3, 0, 1, 1, 1, 0, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0, 2
};
@@ -994,150 +994,150 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
# endif
switch (yytype)
{
- case 3: /* "\"string\"" */
-
-/* Line 650 of yacc.c */
-#line 181 "parse-gram.y"
- { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); };
-
-/* Line 650 of yacc.c */
-#line 1005 "../../src/parse-gram.c"
- break;
- case 4: /* "\"integer\"" */
-
-/* Line 650 of yacc.c */
-#line 192 "parse-gram.y"
- { fprintf (stderr, "%d", ((*yyvaluep).integer)); };
-
-/* Line 650 of yacc.c */
-#line 1014 "../../src/parse-gram.c"
- break;
- case 44: /* "\"{...}\"" */
-
-/* Line 650 of yacc.c */
-#line 183 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); };
-
-/* Line 650 of yacc.c */
-#line 1023 "../../src/parse-gram.c"
- break;
- case 45: /* "\"char\"" */
-
-/* Line 650 of yacc.c */
-#line 175 "parse-gram.y"
- { fputs (char_name (((*yyvaluep).character)), stderr); };
+ case 3: // "string"
-/* Line 650 of yacc.c */
-#line 1032 "../../src/parse-gram.c"
- break;
- case 46: /* "\"epilogue\"" */
+/* Line 647 of yacc.c */
+#line 185 "parse-gram.y"
+ { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); }
+/* Line 647 of yacc.c */
+#line 1004 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 183 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
+ case 4: // "integer"
-/* Line 650 of yacc.c */
-#line 1041 "../../src/parse-gram.c"
- break;
- case 48: /* "\"identifier\"" */
+/* Line 647 of yacc.c */
+#line 197 "parse-gram.y"
+ { fprintf (stderr, "%d", ((*yyvaluep).integer)); }
+/* Line 647 of yacc.c */
+#line 1013 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 188 "parse-gram.y"
- { fputs (((*yyvaluep).uniqstr), stderr); };
+ case 44: // "{...}"
-/* Line 650 of yacc.c */
-#line 1050 "../../src/parse-gram.c"
- break;
- case 49: /* "\"identifier:\"" */
+/* Line 647 of yacc.c */
+#line 187 "parse-gram.y"
+ { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); }
+/* Line 647 of yacc.c */
+#line 1022 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 189 "parse-gram.y"
- { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); };
+ case 45: // "char"
-/* Line 650 of yacc.c */
-#line 1059 "../../src/parse-gram.c"
- break;
- case 52: /* "\"%{...%}\"" */
+/* Line 647 of yacc.c */
+#line 179 "parse-gram.y"
+ { fputs (char_name (((*yyvaluep).character)), stderr); }
+/* Line 647 of yacc.c */
+#line 1031 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 183 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
+ case 46: // "epilogue"
-/* Line 650 of yacc.c */
-#line 1068 "../../src/parse-gram.c"
- break;
- case 54: /* "\"\"" */
-
-/* Line 650 of yacc.c */
+/* Line 647 of yacc.c */
#line 187 "parse-gram.y"
- { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); };
+ { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 647 of yacc.c */
+#line 1040 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1077 "../../src/parse-gram.c"
- break;
- case 83: /* "variable" */
+ case 48: // "identifier"
-/* Line 650 of yacc.c */
-#line 188 "parse-gram.y"
- { fputs (((*yyvaluep).uniqstr), stderr); };
+/* Line 647 of yacc.c */
+#line 193 "parse-gram.y"
+ { fputs (((*yyvaluep).uniqstr), stderr); }
+/* Line 647 of yacc.c */
+#line 1049 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1086 "../../src/parse-gram.c"
- break;
- case 84: /* "content.opt" */
+ case 49: // "identifier:"
-/* Line 650 of yacc.c */
-#line 183 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
+/* Line 647 of yacc.c */
+#line 194 "parse-gram.y"
+ { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); }
+/* Line 647 of yacc.c */
+#line 1058 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1095 "../../src/parse-gram.c"
- break;
- case 85: /* "braceless" */
+ case 52: // "%{...%}"
-/* Line 650 of yacc.c */
-#line 183 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
+/* Line 647 of yacc.c */
+#line 187 "parse-gram.y"
+ { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 647 of yacc.c */
+#line 1067 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1104 "../../src/parse-gram.c"
- break;
- case 86: /* "id" */
+ case 54: // ""
-/* Line 650 of yacc.c */
-#line 195 "parse-gram.y"
- { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); };
+/* Line 647 of yacc.c */
+#line 192 "parse-gram.y"
+ { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); }
+/* Line 647 of yacc.c */
+#line 1076 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1113 "../../src/parse-gram.c"
- break;
- case 87: /* "id_colon" */
+ case 85: // variable
-/* Line 650 of yacc.c */
-#line 196 "parse-gram.y"
- { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); };
+/* Line 647 of yacc.c */
+#line 193 "parse-gram.y"
+ { fputs (((*yyvaluep).uniqstr), stderr); }
+/* Line 647 of yacc.c */
+#line 1085 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1122 "../../src/parse-gram.c"
- break;
- case 88: /* "symbol" */
+ case 86: // content.opt
-/* Line 650 of yacc.c */
-#line 195 "parse-gram.y"
- { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); };
+/* Line 647 of yacc.c */
+#line 187 "parse-gram.y"
+ { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 647 of yacc.c */
+#line 1094 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1131 "../../src/parse-gram.c"
- break;
- case 89: /* "string_as_id" */
+ case 87: // braceless
-/* Line 650 of yacc.c */
-#line 195 "parse-gram.y"
- { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); };
+/* Line 647 of yacc.c */
+#line 187 "parse-gram.y"
+ { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 647 of yacc.c */
+#line 1103 "../bison/src/parse-gram.c"
+ break;
+
+ case 88: // id
+
+/* Line 647 of yacc.c */
+#line 200 "parse-gram.y"
+ { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }
+/* Line 647 of yacc.c */
+#line 1112 "../bison/src/parse-gram.c"
+ break;
+
+ case 89: // id_colon
+
+/* Line 647 of yacc.c */
+#line 201 "parse-gram.y"
+ { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); }
+/* Line 647 of yacc.c */
+#line 1121 "../bison/src/parse-gram.c"
+ break;
+
+ case 90: // symbol
+
+/* Line 647 of yacc.c */
+#line 200 "parse-gram.y"
+ { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }
+/* Line 647 of yacc.c */
+#line 1130 "../bison/src/parse-gram.c"
+ break;
+
+ case 91: // string_as_id
+
+/* Line 647 of yacc.c */
+#line 200 "parse-gram.y"
+ { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }
+/* Line 647 of yacc.c */
+#line 1139 "../bison/src/parse-gram.c"
+ break;
-/* Line 650 of yacc.c */
-#line 1140 "../../src/parse-gram.c"
- break;
default:
break;
}
@@ -1375,14 +1375,14 @@ yytnamerr (char *yyres, const char *yystr)
# endif
/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
+ YYTOKEN while in state YYSTATE. Return the number of bytes copied,
including the terminating null byte. If YYRESULT is null, do not
copy anything; just return the number of bytes that would be
copied. As a special case, return 0 if an ordinary "syntax error"
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
size calculation. */
static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
+yysyntax_error (char *yyresult, int yystate, int yytoken)
{
int yyn = yypact[yystate];
@@ -1390,34 +1390,15 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
return 0;
else
{
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
int yysize_overflow = 0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- int yyx;
-
-# if 0
- /* This is so xgettext sees the translatable formats that are
- constructed on the fly. */
- YY_("syntax error, unexpected %s");
- YY_("syntax error, unexpected %s, expecting %s");
- YY_("syntax error, unexpected %s, expecting %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
- char *yyfmt;
- char const *yyf;
- static char const yyunexpected[] = "syntax error, unexpected %s";
- static char const yyexpecting[] = ", expecting %s";
- static char const yyor[] = " or %s";
- char yyformat[sizeof yyunexpected
- + sizeof yyexpecting - 1
- + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
- * (sizeof yyor - 1))];
- char const *yyprefix = yyexpecting;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
@@ -1426,10 +1407,12 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 1;
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+ int yyx;
- yyarg[0] = yytname[yytype];
- yyfmt = yystpcpy (yyformat, yyunexpected);
+ yyarg[yycount++] = yytname[yytoken];
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
@@ -1438,19 +1421,29 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
{
yycount = 1;
yysize = yysize0;
- yyformat[sizeof yyunexpected - 1] = '\0';
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
- yyfmt = yystpcpy (yyfmt, yyprefix);
- yyprefix = yyor;
}
- yyf = YY_(yyformat);
- yysize1 = yysize + yystrlen (yyf);
+ switch (yycount)
+ {
+#define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+#undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
@@ -1464,19 +1457,17 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
produced a string with the wrong number of "%s"s. */
char *yyp = yyresult;
int yyi = 0;
- while ((*yyp = *yyf) != '\0')
- {
- if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyf += 2;
- }
- else
- {
- yyp++;
- yyf++;
- }
- }
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
}
return yysize;
}
@@ -1511,7 +1502,6 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
switch (yytype)
{
-
default:
break;
}
@@ -1519,13 +1509,15 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
int yyparse (void);
#else
int yyparse ();
@@ -1656,18 +1648,16 @@ YYLTYPE yylloc;
#endif
/* User initialization code. */
-
-/* Line 1179 of yacc.c */
-#line 84 "parse-gram.y"
+/* Line 1167 of yacc.c */
+#line 86 "parse-gram.y"
{
/* Bison's grammar can initial empty locations, hence a default
location is needed. */
boundary_set (&yylloc.start, current_file, 1, 1);
boundary_set (&yylloc.end, current_file, 1, 1);
}
-
-/* Line 1179 of yacc.c */
-#line 1671 "../../src/parse-gram.c"
+/* Line 1167 of yacc.c */
+#line 1661 "../bison/src/parse-gram.c"
yylsp[0] = yylloc;
goto yysetstate;
@@ -1853,9 +1843,8 @@ yyreduce:
switch (yyn)
{
case 6:
-
-/* Line 1392 of yacc.c */
-#line 219 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 224 "parse-gram.y"
{
code_props plain_code;
code_props_plain_init (&plain_code, (yyvsp[0].chars), (yylsp[0]));
@@ -1865,123 +1854,101 @@ yyreduce:
plain_code.code, (yylsp[0]));
code_scanner_last_string_free ();
}
-
-/* Line 1392 of yacc.c */
-#line 1871 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1859 "../bison/src/parse-gram.c"
break;
case 7:
-
-/* Line 1392 of yacc.c */
-#line 228 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 233 "parse-gram.y"
{ debug_flag = true; }
-
-/* Line 1392 of yacc.c */
-#line 1881 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1867 "../bison/src/parse-gram.c"
break;
case 8:
-
-/* Line 1392 of yacc.c */
-#line 230 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 235 "parse-gram.y"
{
muscle_percent_define_insert ((yyvsp[-1].uniqstr), (yylsp[-1]), (yyvsp[0].chars));
}
-
-/* Line 1392 of yacc.c */
-#line 1893 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1877 "../bison/src/parse-gram.c"
break;
case 9:
-
-/* Line 1392 of yacc.c */
-#line 233 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 238 "parse-gram.y"
{ defines_flag = true; }
-
-/* Line 1392 of yacc.c */
-#line 1903 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1885 "../bison/src/parse-gram.c"
break;
case 10:
-
-/* Line 1392 of yacc.c */
-#line 235 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 240 "parse-gram.y"
{
defines_flag = true;
spec_defines_file = xstrdup ((yyvsp[0].chars));
}
-
-/* Line 1392 of yacc.c */
-#line 1916 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1896 "../bison/src/parse-gram.c"
break;
case 11:
-
-/* Line 1392 of yacc.c */
-#line 239 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 244 "parse-gram.y"
{ error_verbose = true; }
-
-/* Line 1392 of yacc.c */
-#line 1926 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1904 "../bison/src/parse-gram.c"
break;
case 12:
-
-/* Line 1392 of yacc.c */
-#line 240 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 245 "parse-gram.y"
{ expected_sr_conflicts = (yyvsp[0].integer); }
-
-/* Line 1392 of yacc.c */
-#line 1936 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1912 "../bison/src/parse-gram.c"
break;
case 13:
-
-/* Line 1392 of yacc.c */
-#line 241 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 246 "parse-gram.y"
{ expected_rr_conflicts = (yyvsp[0].integer); }
-
-/* Line 1392 of yacc.c */
-#line 1946 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1920 "../bison/src/parse-gram.c"
break;
case 14:
-
-/* Line 1392 of yacc.c */
-#line 242 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 247 "parse-gram.y"
{ spec_file_prefix = (yyvsp[0].chars); }
-
-/* Line 1392 of yacc.c */
-#line 1956 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1928 "../bison/src/parse-gram.c"
break;
case 15:
-
-/* Line 1392 of yacc.c */
-#line 243 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 248 "parse-gram.y"
{ spec_file_prefix = (yyvsp[0].chars); }
-
-/* Line 1392 of yacc.c */
-#line 1966 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1936 "../bison/src/parse-gram.c"
break;
case 16:
-
-/* Line 1392 of yacc.c */
-#line 245 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 250 "parse-gram.y"
{
nondeterministic_parser = true;
glr_parser = true;
}
-
-/* Line 1392 of yacc.c */
-#line 1979 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1947 "../bison/src/parse-gram.c"
break;
case 17:
-
-/* Line 1392 of yacc.c */
-#line 250 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 255 "parse-gram.y"
{
code_props action;
code_props_symbol_action_init (&action, (yyvsp[0].code), (yylsp[0]));
@@ -1990,115 +1957,93 @@ yyreduce:
muscle_code_grow ("initial_action", action.code, (yylsp[0]));
code_scanner_last_string_free ();
}
-
-/* Line 1392 of yacc.c */
-#line 1996 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1962 "../bison/src/parse-gram.c"
break;
case 18:
-
-/* Line 1392 of yacc.c */
-#line 258 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 263 "parse-gram.y"
{ language_argmatch ((yyvsp[0].chars), grammar_prio, (yylsp[-1])); }
-
-/* Line 1392 of yacc.c */
-#line 2006 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1970 "../bison/src/parse-gram.c"
break;
case 19:
-
-/* Line 1392 of yacc.c */
-#line 259 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 264 "parse-gram.y"
{ add_param ("lex_param", (yyvsp[0].code), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2016 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1978 "../bison/src/parse-gram.c"
break;
case 20:
-
-/* Line 1392 of yacc.c */
-#line 260 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 265 "parse-gram.y"
{ locations_flag = true; }
-
-/* Line 1392 of yacc.c */
-#line 2026 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1986 "../bison/src/parse-gram.c"
break;
case 21:
-
-/* Line 1392 of yacc.c */
-#line 261 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 266 "parse-gram.y"
{ spec_name_prefix = (yyvsp[0].chars); }
-
-/* Line 1392 of yacc.c */
-#line 2036 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 1994 "../bison/src/parse-gram.c"
break;
case 22:
-
-/* Line 1392 of yacc.c */
-#line 262 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 267 "parse-gram.y"
{ spec_name_prefix = (yyvsp[0].chars); }
-
-/* Line 1392 of yacc.c */
-#line 2046 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2002 "../bison/src/parse-gram.c"
break;
case 23:
-
-/* Line 1392 of yacc.c */
-#line 263 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 268 "parse-gram.y"
{ no_lines_flag = true; }
-
-/* Line 1392 of yacc.c */
-#line 2056 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2010 "../bison/src/parse-gram.c"
break;
case 24:
-
-/* Line 1392 of yacc.c */
-#line 264 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 269 "parse-gram.y"
{ nondeterministic_parser = true; }
-
-/* Line 1392 of yacc.c */
-#line 2066 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2018 "../bison/src/parse-gram.c"
break;
case 25:
-
-/* Line 1392 of yacc.c */
-#line 265 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 270 "parse-gram.y"
{ spec_outfile = (yyvsp[0].chars); }
-
-/* Line 1392 of yacc.c */
-#line 2076 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2026 "../bison/src/parse-gram.c"
break;
case 26:
-
-/* Line 1392 of yacc.c */
-#line 266 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 271 "parse-gram.y"
{ spec_outfile = (yyvsp[0].chars); }
-
-/* Line 1392 of yacc.c */
-#line 2086 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2034 "../bison/src/parse-gram.c"
break;
case 27:
-
-/* Line 1392 of yacc.c */
-#line 267 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 272 "parse-gram.y"
{ add_param ("parse_param", (yyvsp[0].code), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2096 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2042 "../bison/src/parse-gram.c"
break;
case 28:
-
-/* Line 1392 of yacc.c */
-#line 269 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 274 "parse-gram.y"
{
/* %pure-parser is deprecated in favor of `%define api.pure', so use
`%define api.pure' in a backward-compatible manner here. First, don't
@@ -2111,25 +2056,21 @@ yyreduce:
if (!muscle_percent_define_flag_if ("api.pure"))
muscle_percent_define_insert ("api.pure", (yylsp[0]), "");
}
-
-/* Line 1392 of yacc.c */
-#line 2117 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2061 "../bison/src/parse-gram.c"
break;
case 29:
-
-/* Line 1392 of yacc.c */
-#line 281 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 286 "parse-gram.y"
{ version_check (&(yylsp[0]), (yyvsp[0].chars)); }
-
-/* Line 1392 of yacc.c */
-#line 2127 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2069 "../bison/src/parse-gram.c"
break;
case 30:
-
-/* Line 1392 of yacc.c */
-#line 283 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 288 "parse-gram.y"
{
char const *skeleton_user = (yyvsp[0].chars);
if (strchr (skeleton_user, '/'))
@@ -2153,219 +2094,183 @@ yyreduce:
}
skeleton_arg (skeleton_user, grammar_prio, (yylsp[-1]));
}
-
-/* Line 1392 of yacc.c */
-#line 2159 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2099 "../bison/src/parse-gram.c"
break;
case 31:
-
-/* Line 1392 of yacc.c */
-#line 306 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 311 "parse-gram.y"
{ token_table_flag = true; }
-
-/* Line 1392 of yacc.c */
-#line 2169 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2107 "../bison/src/parse-gram.c"
break;
case 32:
-
-/* Line 1392 of yacc.c */
-#line 307 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 312 "parse-gram.y"
{ report_flag |= report_states; }
-
-/* Line 1392 of yacc.c */
-#line 2179 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2115 "../bison/src/parse-gram.c"
break;
case 33:
-
-/* Line 1392 of yacc.c */
-#line 308 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 313 "parse-gram.y"
{ yacc_flag = true; }
-
-/* Line 1392 of yacc.c */
-#line 2189 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2123 "../bison/src/parse-gram.c"
break;
case 37:
-
-/* Line 1392 of yacc.c */
-#line 316 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 321 "parse-gram.y"
{
grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0]));
}
-
-/* Line 1392 of yacc.c */
-#line 2201 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2133 "../bison/src/parse-gram.c"
break;
case 38:
-
-/* Line 1392 of yacc.c */
-#line 320 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 325 "parse-gram.y"
{
symbol_list *list;
for (list = (yyvsp[0].list); list; list = list->next)
symbol_list_destructor_set (list, (yyvsp[-1].code), (yylsp[-1]));
symbol_list_free ((yyvsp[0].list));
}
-
-/* Line 1392 of yacc.c */
-#line 2216 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2146 "../bison/src/parse-gram.c"
break;
case 39:
-
-/* Line 1392 of yacc.c */
-#line 327 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 332 "parse-gram.y"
{
symbol_list *list;
for (list = (yyvsp[0].list); list; list = list->next)
symbol_list_printer_set (list, (yyvsp[-1].code), (yylsp[-1]));
symbol_list_free ((yyvsp[0].list));
}
-
-/* Line 1392 of yacc.c */
-#line 2231 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2159 "../bison/src/parse-gram.c"
break;
case 40:
-
-/* Line 1392 of yacc.c */
-#line 334 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 339 "parse-gram.y"
{
default_prec = true;
}
-
-/* Line 1392 of yacc.c */
-#line 2243 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2169 "../bison/src/parse-gram.c"
break;
case 41:
-
-/* Line 1392 of yacc.c */
-#line 338 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 343 "parse-gram.y"
{
default_prec = false;
}
-
-/* Line 1392 of yacc.c */
-#line 2255 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2179 "../bison/src/parse-gram.c"
break;
case 42:
-
-/* Line 1392 of yacc.c */
-#line 342 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 347 "parse-gram.y"
{
/* Do not invoke muscle_percent_code_grow here since it invokes
muscle_user_name_list_grow. */
muscle_code_grow ("percent_code()", (yyvsp[0].chars), (yylsp[0]));
code_scanner_last_string_free ();
}
-
-/* Line 1392 of yacc.c */
-#line 2270 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2192 "../bison/src/parse-gram.c"
break;
case 43:
-
-/* Line 1392 of yacc.c */
-#line 349 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 354 "parse-gram.y"
{
muscle_percent_code_grow ((yyvsp[-1].uniqstr), (yylsp[-1]), (yyvsp[0].chars), (yylsp[0]));
code_scanner_last_string_free ();
}
-
-/* Line 1392 of yacc.c */
-#line 2283 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2203 "../bison/src/parse-gram.c"
break;
case 44:
-
-/* Line 1392 of yacc.c */
-#line 363 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 368 "parse-gram.y"
{}
-
-/* Line 1392 of yacc.c */
-#line 2293 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2211 "../bison/src/parse-gram.c"
break;
case 45:
-
-/* Line 1392 of yacc.c */
-#line 364 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 369 "parse-gram.y"
{ muscle_code_grow ("union_name", (yyvsp[0].uniqstr), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2303 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2219 "../bison/src/parse-gram.c"
break;
case 46:
-
-/* Line 1392 of yacc.c */
-#line 369 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 374 "parse-gram.y"
{
union_seen = true;
muscle_code_grow ("stype", (yyvsp[0].chars), (yylsp[0]));
code_scanner_last_string_free ();
}
-
-/* Line 1392 of yacc.c */
-#line 2317 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2231 "../bison/src/parse-gram.c"
break;
case 47:
-
-/* Line 1392 of yacc.c */
-#line 380 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 385 "parse-gram.y"
{ current_class = nterm_sym; }
-
-/* Line 1392 of yacc.c */
-#line 2327 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2239 "../bison/src/parse-gram.c"
break;
case 48:
-
-/* Line 1392 of yacc.c */
-#line 381 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 386 "parse-gram.y"
{
current_class = unknown_sym;
current_type = NULL;
}
-
-/* Line 1392 of yacc.c */
-#line 2340 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2250 "../bison/src/parse-gram.c"
break;
case 49:
-
-/* Line 1392 of yacc.c */
-#line 385 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 390 "parse-gram.y"
{ current_class = token_sym; }
-
-/* Line 1392 of yacc.c */
-#line 2350 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2258 "../bison/src/parse-gram.c"
break;
case 50:
-
-/* Line 1392 of yacc.c */
-#line 386 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 391 "parse-gram.y"
{
current_class = unknown_sym;
current_type = NULL;
}
-
-/* Line 1392 of yacc.c */
-#line 2363 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2269 "../bison/src/parse-gram.c"
break;
case 51:
-
-/* Line 1392 of yacc.c */
-#line 391 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 396 "parse-gram.y"
{
symbol_list *list;
tag_seen = true;
@@ -2373,15 +2278,13 @@ yyreduce:
symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1]));
symbol_list_free ((yyvsp[0].list));
}
-
-/* Line 1392 of yacc.c */
-#line 2379 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2283 "../bison/src/parse-gram.c"
break;
case 52:
-
-/* Line 1392 of yacc.c */
-#line 402 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 407 "parse-gram.y"
{
symbol_list *list;
++current_prec;
@@ -2393,388 +2296,334 @@ yyreduce:
symbol_list_free ((yyvsp[0].list));
current_type = NULL;
}
-
-/* Line 1392 of yacc.c */
-#line 2399 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2301 "../bison/src/parse-gram.c"
break;
case 53:
-
-/* Line 1392 of yacc.c */
-#line 416 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 421 "parse-gram.y"
{ (yyval.assoc) = left_assoc; }
-
-/* Line 1392 of yacc.c */
-#line 2409 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2309 "../bison/src/parse-gram.c"
break;
case 54:
-
-/* Line 1392 of yacc.c */
-#line 417 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 422 "parse-gram.y"
{ (yyval.assoc) = right_assoc; }
-
-/* Line 1392 of yacc.c */
-#line 2419 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2317 "../bison/src/parse-gram.c"
break;
case 55:
-
-/* Line 1392 of yacc.c */
-#line 418 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 423 "parse-gram.y"
{ (yyval.assoc) = non_assoc; }
-
-/* Line 1392 of yacc.c */
-#line 2429 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2325 "../bison/src/parse-gram.c"
break;
case 56:
-
-/* Line 1392 of yacc.c */
-#line 419 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 424 "parse-gram.y"
{ (yyval.assoc) = precedence_assoc; }
-
-/* Line 1392 of yacc.c */
-#line 2439 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2333 "../bison/src/parse-gram.c"
break;
case 57:
-
-/* Line 1392 of yacc.c */
-#line 423 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 428 "parse-gram.y"
{ current_type = NULL; }
-
-/* Line 1392 of yacc.c */
-#line 2449 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2341 "../bison/src/parse-gram.c"
break;
case 58:
-
-/* Line 1392 of yacc.c */
-#line 424 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 429 "parse-gram.y"
{ current_type = (yyvsp[0].uniqstr); tag_seen = true; }
-
-/* Line 1392 of yacc.c */
-#line 2459 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2349 "../bison/src/parse-gram.c"
break;
case 59:
-
-/* Line 1392 of yacc.c */
-#line 430 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 435 "parse-gram.y"
{ (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2469 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2357 "../bison/src/parse-gram.c"
break;
case 60:
-
-/* Line 1392 of yacc.c */
-#line 432 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 437 "parse-gram.y"
{ (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); }
-
-/* Line 1392 of yacc.c */
-#line 2479 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2365 "../bison/src/parse-gram.c"
break;
case 61:
-
-/* Line 1392 of yacc.c */
-#line 436 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 441 "parse-gram.y"
{ (yyval.symbol) = (yyvsp[0].symbol); }
-
-/* Line 1392 of yacc.c */
-#line 2489 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2373 "../bison/src/parse-gram.c"
break;
case 62:
-
-/* Line 1392 of yacc.c */
-#line 437 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 442 "parse-gram.y"
{ (yyval.symbol) = (yyvsp[-1].symbol); symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2499 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2381 "../bison/src/parse-gram.c"
break;
case 63:
-
-/* Line 1392 of yacc.c */
-#line 443 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 448 "parse-gram.y"
{ (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2509 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2389 "../bison/src/parse-gram.c"
break;
case 64:
-
-/* Line 1392 of yacc.c */
-#line 445 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 450 "parse-gram.y"
{ (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); }
-
-/* Line 1392 of yacc.c */
-#line 2519 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2397 "../bison/src/parse-gram.c"
break;
case 65:
-
-/* Line 1392 of yacc.c */
-#line 449 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 454 "parse-gram.y"
{ (yyval.list) = (yyvsp[0].list); }
-
-/* Line 1392 of yacc.c */
-#line 2529 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2405 "../bison/src/parse-gram.c"
break;
case 66:
-
-/* Line 1392 of yacc.c */
-#line 450 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 455 "parse-gram.y"
{ (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), (yyvsp[0].list)); }
-
-/* Line 1392 of yacc.c */
-#line 2539 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2413 "../bison/src/parse-gram.c"
break;
case 67:
-
-/* Line 1392 of yacc.c */
-#line 454 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 459 "parse-gram.y"
{ (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2549 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2421 "../bison/src/parse-gram.c"
break;
case 68:
-
-/* Line 1392 of yacc.c */
-#line 455 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 460 "parse-gram.y"
{ (yyval.list) = symbol_list_type_new ((yyvsp[0].uniqstr), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2559 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2429 "../bison/src/parse-gram.c"
break;
case 69:
-
-/* Line 1392 of yacc.c */
-#line 456 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 461 "parse-gram.y"
{ (yyval.list) = symbol_list_default_tagged_new ((yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2569 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2437 "../bison/src/parse-gram.c"
break;
case 70:
-
-/* Line 1392 of yacc.c */
-#line 457 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 462 "parse-gram.y"
{ (yyval.list) = symbol_list_default_tagless_new ((yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2579 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2445 "../bison/src/parse-gram.c"
break;
case 71:
-
-/* Line 1392 of yacc.c */
-#line 463 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 468 "parse-gram.y"
{
current_type = (yyvsp[0].uniqstr);
tag_seen = true;
}
-
-/* Line 1392 of yacc.c */
-#line 2592 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2456 "../bison/src/parse-gram.c"
break;
case 72:
-
-/* Line 1392 of yacc.c */
-#line 468 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 473 "parse-gram.y"
{
symbol_class_set ((yyvsp[0].symbol), current_class, (yylsp[0]), true);
symbol_type_set ((yyvsp[0].symbol), current_type, (yylsp[0]));
}
-
-/* Line 1392 of yacc.c */
-#line 2605 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2467 "../bison/src/parse-gram.c"
break;
case 73:
-
-/* Line 1392 of yacc.c */
-#line 473 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 478 "parse-gram.y"
{
symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true);
symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1]));
symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0]));
}
-
-/* Line 1392 of yacc.c */
-#line 2619 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2479 "../bison/src/parse-gram.c"
break;
case 74:
-
-/* Line 1392 of yacc.c */
-#line 479 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 484 "parse-gram.y"
{
symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true);
symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1]));
symbol_make_alias ((yyvsp[-1].symbol), (yyvsp[0].symbol), (yyloc));
}
-
-/* Line 1392 of yacc.c */
-#line 2633 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2491 "../bison/src/parse-gram.c"
break;
case 75:
-
-/* Line 1392 of yacc.c */
-#line 485 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 490 "parse-gram.y"
{
symbol_class_set ((yyvsp[-2].symbol), current_class, (yylsp[-2]), true);
symbol_type_set ((yyvsp[-2].symbol), current_type, (yylsp[-2]));
symbol_user_token_number_set ((yyvsp[-2].symbol), (yyvsp[-1].integer), (yylsp[-1]));
symbol_make_alias ((yyvsp[-2].symbol), (yyvsp[0].symbol), (yyloc));
}
-
-/* Line 1392 of yacc.c */
-#line 2648 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2504 "../bison/src/parse-gram.c"
break;
case 82:
-
-/* Line 1392 of yacc.c */
-#line 515 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 520 "parse-gram.y"
{
yyerrok;
}
-
-/* Line 1392 of yacc.c */
-#line 2660 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2514 "../bison/src/parse-gram.c"
break;
case 83:
-
-/* Line 1392 of yacc.c */
-#line 521 "parse-gram.y"
- { current_lhs = (yyvsp[0].symbol); current_lhs_location = (yylsp[0]); }
-
-/* Line 1392 of yacc.c */
-#line 2670 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 526 "parse-gram.y"
+ { current_lhs = (yyvsp[-1].symbol); current_lhs_location = (yylsp[-1]);
+ current_lhs_named_ref = (yyvsp[0].named_ref); }
+/* Line 1380 of yacc.c */
+#line 2523 "../bison/src/parse-gram.c"
break;
case 85:
-
-/* Line 1392 of yacc.c */
-#line 525 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 531 "parse-gram.y"
{ grammar_current_rule_end ((yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2680 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2531 "../bison/src/parse-gram.c"
break;
case 86:
-
-/* Line 1392 of yacc.c */
-#line 526 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 532 "parse-gram.y"
{ grammar_current_rule_end ((yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2690 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2539 "../bison/src/parse-gram.c"
break;
case 88:
-
-/* Line 1392 of yacc.c */
-#line 532 "parse-gram.y"
- { grammar_current_rule_begin (current_lhs, current_lhs_location); }
-
-/* Line 1392 of yacc.c */
-#line 2700 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 538 "parse-gram.y"
+ { grammar_current_rule_begin (current_lhs, current_lhs_location,
+ current_lhs_named_ref); }
+/* Line 1380 of yacc.c */
+#line 2548 "../bison/src/parse-gram.c"
break;
case 89:
-
-/* Line 1392 of yacc.c */
-#line 534 "parse-gram.y"
- { grammar_current_rule_symbol_append ((yyvsp[0].symbol), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2710 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 541 "parse-gram.y"
+ { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].named_ref)); }
+/* Line 1380 of yacc.c */
+#line 2556 "../bison/src/parse-gram.c"
break;
case 90:
-
-/* Line 1392 of yacc.c */
-#line 536 "parse-gram.y"
- { grammar_current_rule_action_append ((yyvsp[0].code), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2720 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 543 "parse-gram.y"
+ { grammar_current_rule_action_append ((yyvsp[-1].code), (yylsp[-1]), (yyvsp[0].named_ref)); }
+/* Line 1380 of yacc.c */
+#line 2564 "../bison/src/parse-gram.c"
break;
case 91:
-
-/* Line 1392 of yacc.c */
-#line 538 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 545 "parse-gram.y"
{ grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2730 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2572 "../bison/src/parse-gram.c"
break;
case 92:
-
-/* Line 1392 of yacc.c */
-#line 540 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 547 "parse-gram.y"
{ grammar_current_rule_dprec_set ((yyvsp[0].integer), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2740 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2580 "../bison/src/parse-gram.c"
break;
case 93:
-
-/* Line 1392 of yacc.c */
-#line 542 "parse-gram.y"
+/* Line 1380 of yacc.c */
+#line 549 "parse-gram.y"
{ grammar_current_rule_merge_set ((yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1380 of yacc.c */
+#line 2588 "../bison/src/parse-gram.c"
+ break;
-/* Line 1392 of yacc.c */
-#line 2750 "../../src/parse-gram.c"
+ case 94:
+/* Line 1380 of yacc.c */
+#line 554 "parse-gram.y"
+ { (yyval.named_ref) = 0; }
+/* Line 1380 of yacc.c */
+#line 2596 "../bison/src/parse-gram.c"
break;
case 95:
+/* Line 1380 of yacc.c */
+#line 557 "parse-gram.y"
+ { (yyval.named_ref) = named_ref_new((yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1380 of yacc.c */
+#line 2604 "../bison/src/parse-gram.c"
+ break;
-/* Line 1392 of yacc.c */
-#line 552 "parse-gram.y"
+ case 97:
+/* Line 1380 of yacc.c */
+#line 567 "parse-gram.y"
{ (yyval.uniqstr) = uniqstr_new ((yyvsp[0].chars)); }
-
-/* Line 1392 of yacc.c */
-#line 2760 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2612 "../bison/src/parse-gram.c"
break;
- case 96:
-
-/* Line 1392 of yacc.c */
-#line 558 "parse-gram.y"
+ case 98:
+/* Line 1380 of yacc.c */
+#line 573 "parse-gram.y"
{
(yyval.chars) = "";
}
-
-/* Line 1392 of yacc.c */
-#line 2772 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2622 "../bison/src/parse-gram.c"
break;
- case 98:
-
-/* Line 1392 of yacc.c */
-#line 571 "parse-gram.y"
+ case 100:
+/* Line 1380 of yacc.c */
+#line 586 "parse-gram.y"
{
code_props plain_code;
(yyvsp[0].code)[strlen ((yyvsp[0].code)) - 1] = '\n';
@@ -2783,62 +2632,52 @@ yyreduce:
gram_scanner_last_string_free ();
(yyval.chars) = plain_code.code;
}
-
-/* Line 1392 of yacc.c */
-#line 2789 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2637 "../bison/src/parse-gram.c"
break;
- case 99:
-
-/* Line 1392 of yacc.c */
-#line 591 "parse-gram.y"
+ case 101:
+/* Line 1380 of yacc.c */
+#line 606 "parse-gram.y"
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2799 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2645 "../bison/src/parse-gram.c"
break;
- case 100:
-
-/* Line 1392 of yacc.c */
-#line 593 "parse-gram.y"
+ case 102:
+/* Line 1380 of yacc.c */
+#line 608 "parse-gram.y"
{
(yyval.symbol) = symbol_get (char_name ((yyvsp[0].character)), (yylsp[0]));
symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false);
symbol_user_token_number_set ((yyval.symbol), (yyvsp[0].character), (yylsp[0]));
}
-
-/* Line 1392 of yacc.c */
-#line 2813 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2657 "../bison/src/parse-gram.c"
break;
- case 101:
-
-/* Line 1392 of yacc.c */
-#line 601 "parse-gram.y"
+ case 103:
+/* Line 1380 of yacc.c */
+#line 616 "parse-gram.y"
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); }
-
-/* Line 1392 of yacc.c */
-#line 2823 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2665 "../bison/src/parse-gram.c"
break;
- case 104:
-
-/* Line 1392 of yacc.c */
-#line 613 "parse-gram.y"
+ case 106:
+/* Line 1380 of yacc.c */
+#line 628 "parse-gram.y"
{
(yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].chars)), (yylsp[0]));
symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false);
}
-
-/* Line 1392 of yacc.c */
-#line 2836 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2676 "../bison/src/parse-gram.c"
break;
- case 106:
-
-/* Line 1392 of yacc.c */
-#line 622 "parse-gram.y"
+ case 108:
+/* Line 1380 of yacc.c */
+#line 637 "parse-gram.y"
{
code_props plain_code;
code_props_plain_init (&plain_code, (yyvsp[0].chars), (yylsp[0]));
@@ -2847,15 +2686,13 @@ yyreduce:
muscle_code_grow ("epilogue", plain_code.code, (yylsp[0]));
code_scanner_last_string_free ();
}
-
-/* Line 1392 of yacc.c */
-#line 2853 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2691 "../bison/src/parse-gram.c"
break;
-
-/* Line 1392 of yacc.c */
-#line 2859 "../../src/parse-gram.c"
+/* Line 1380 of yacc.c */
+#line 2696 "../bison/src/parse-gram.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2894,7 +2731,7 @@ yyerrlab:
yyerror (YY_("syntax error"));
#else
{
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+ YYSIZE_T yysize = yysyntax_error (0, yystate, yytoken);
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
{
YYSIZE_T yyalloc = 2 * yysize;
@@ -2914,7 +2751,7 @@ yyerrlab:
if (0 < yysize && yysize <= yymsg_alloc)
{
- (void) yysyntax_error (yymsg, yystate, yychar);
+ (void) yysyntax_error (yymsg, yystate, yytoken);
yyerror (yymsg);
}
else
@@ -3071,10 +2908,8 @@ yyreturn:
return YYID (yyresult);
}
-
-
-/* Line 1612 of yacc.c */
-#line 632 "parse-gram.y"
+/* Line 1599 of yacc.c */
+#line 647 "parse-gram.y"
@@ -3195,4 +3030,3 @@ char_name (char c)
return quotearg_style (escape_quoting_style, buf);
}
}
-
diff --git a/src/parse-gram.h b/src/parse-gram.h
index b3d5119..409c894 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.4.194-c20a1-dirty. */
+/* A Bison parser, made by GNU Bison 2.4.259-91be6-dirty. */
/* Interface for Bison's Yacc-like parsers in C
@@ -92,7 +92,8 @@
TAG = 309,
TAG_ANY = 310,
TAG_NONE = 311,
- PERCENT_UNION = 312
+ BRACKETED_ID = 312,
+ PERCENT_UNION = 313
};
#endif
/* Tokens. */
@@ -151,7 +152,8 @@
#define TAG 309
#define TAG_ANY 310
#define TAG_NONE 311
-#define PERCENT_UNION 312
+#define BRACKETED_ID 312
+#define PERCENT_UNION 313
@@ -159,9 +161,8 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
-
-/* Line 1613 of yacc.c */
-#line 92 "parse-gram.y"
+/* Line 1600 of yacc.c */
+#line 94 "parse-gram.y"
symbol *symbol;
symbol_list *list;
@@ -171,11 +172,11 @@ typedef union YYSTYPE
assoc assoc;
uniqstr uniqstr;
unsigned char character;
+ named_ref *named_ref;
-
-/* Line 1613 of yacc.c */
-#line 179 "../../src/parse-gram.h"
+/* Line 1600 of yacc.c */
+#line 180 "../bison/src/parse-gram.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
diff --git a/src/parse-gram.y b/src/parse-gram.y
index cada04f..2a091c5 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -30,6 +30,7 @@
#include "quotearg.h"
#include "reader.h"
#include "symlist.h"
+#include "named-ref.h"
#include "scan-gram.h"
#include "scan-code.h"
@@ -63,6 +64,7 @@ static symbol_class current_class = unknown_sym;
static uniqstr current_type = NULL;
static symbol *current_lhs;
static location current_lhs_location;
+static named_ref *current_lhs_named_ref;
static int current_prec = 0;
#define YYTYPE_INT16 int_fast16_t
@@ -98,6 +100,7 @@ static int current_prec = 0;
assoc assoc;
uniqstr uniqstr;
unsigned char character;
+ named_ref *named_ref;
};
/* Define the tokens together with their human representation. */
@@ -170,6 +173,7 @@ static int current_prec = 0;
%token TAG ""
%token TAG_ANY "<*>"
%token TAG_NONE "<>"
+%token BRACKETED_ID "[id]"
%type CHAR
%printer { fputs (char_name ($$), stderr); } CHAR
@@ -183,7 +187,8 @@ static int current_prec = 0;
%printer { fprintf (stderr, "{\n%s\n}", $$); }
braceless content.opt "{...}" "%{...%}" EPILOGUE
-%type TAG ID ID_COLON variable
+%type TAG ID ID_COLON BRACKETED_ID variable
+%type named_ref.opt
%printer { fprintf (stderr, "<%s>", $$); } TAG
%printer { fputs ($$, stderr); } ID variable
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
@@ -518,7 +523,8 @@ rules_or_grammar_declaration:
;
rules:
- id_colon { current_lhs = $1; current_lhs_location = @1; } rhses.1
+ id_colon named_ref.opt { current_lhs = $1; current_lhs_location = @1;
+ current_lhs_named_ref = $2; } rhses.1
;
rhses.1:
@@ -529,11 +535,12 @@ rhses.1:
rhs:
/* Nothing. */
- { grammar_current_rule_begin (current_lhs, current_lhs_location); }
-| rhs symbol
- { grammar_current_rule_symbol_append ($2, @2); }
-| rhs "{...}"
- { grammar_current_rule_action_append ($2, @2); }
+ { grammar_current_rule_begin (current_lhs, current_lhs_location,
+ current_lhs_named_ref); }
+| rhs symbol named_ref.opt
+ { grammar_current_rule_symbol_append ($2, @2, $3); }
+| rhs "{...}" named_ref.opt
+ { grammar_current_rule_action_append ($2, @2, $3); }
| rhs "%prec" symbol
{ grammar_current_rule_prec_set ($3, @3); }
| rhs "%dprec" INT
@@ -542,6 +549,14 @@ rhs:
{ grammar_current_rule_merge_set ($3, @3); }
;
+named_ref.opt:
+ /* Nothing. */
+ { $$ = 0; }
+|
+ BRACKETED_ID
+ { $$ = named_ref_new($1, @1); }
+;
+
/*---------------------------.
| variable and content.opt. |
diff --git a/src/reader.c b/src/reader.c
index 7758c77..d09121c 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -21,6 +21,7 @@
#include
#include "system.h"
+#include
#include
#include "complain.h"
@@ -169,7 +170,7 @@ free_merger_functions (void)
static symbol_list *grammar_end = NULL;
/* Append SYM to the grammar. */
-static void
+static symbol_list *
grammar_symbol_append (symbol *sym, location loc)
{
symbol_list *p = symbol_list_sym_new (sym, loc);
@@ -185,6 +186,8 @@ grammar_symbol_append (symbol *sym, location loc)
part of it. */
if (sym)
++nritems;
+
+ return p;
}
/* The rule currently being defined, and the previous rule.
@@ -199,12 +202,28 @@ static symbol_list *previous_rule_end = NULL;
`----------------------------------------------*/
void
-grammar_current_rule_begin (symbol *lhs, location loc)
+grammar_current_rule_begin (symbol *lhs, location loc, named_ref* lhs_named_ref)
{
+ symbol_list* p;
+
/* Start a new rule and record its lhs. */
++nrules;
previous_rule_end = grammar_end;
- grammar_symbol_append (lhs, loc);
+
+ p = grammar_symbol_append (lhs, loc);
+ if (lhs_named_ref)
+ {
+ if (lhs_named_ref->id == lhs->tag)
+ {
+ warn_at (lhs_named_ref->loc,
+ _("duplicated symbol name for %s ignored"),
+ quote (lhs->tag));
+ named_ref_free (lhs_named_ref);
+ }
+ else
+ p->named_ref = lhs_named_ref;
+ }
+
current_rule = grammar_end;
/* Mark the rule's lhs as a nonterminal if not already so. */
@@ -328,6 +347,9 @@ grammar_midrule_action (void)
symbol *dummy = dummy_symbol_get (dummy_location);
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location);
+ /* Remember named_ref of previous action */
+ named_ref* named_ref = current_rule->action_props.named_ref;
+
/* Make a new rule, whose body is empty, before the current one, so
that the action just read can belong to it. */
++nrules;
@@ -337,7 +359,7 @@ grammar_midrule_action (void)
code_props_rule_action_init (&midrule->action_props,
current_rule->action_props.code,
current_rule->action_props.location,
- midrule);
+ midrule, 0);
code_props_none_init (¤t_rule->action_props);
if (previous_rule_end)
@@ -353,7 +375,7 @@ grammar_midrule_action (void)
/* Insert the dummy nonterminal replacing the midrule action into
the current rule. Bind it to its dedicated rule. */
- grammar_current_rule_symbol_append (dummy, dummy_location);
+ grammar_current_rule_symbol_append (dummy, dummy_location, named_ref);
grammar_end->midrule = midrule;
midrule->midrule_parent_rule = current_rule;
midrule->midrule_parent_rhs_index = symbol_list_length (current_rule->next);
@@ -402,24 +424,40 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
action as a mid-rule action. */
void
-grammar_current_rule_symbol_append (symbol *sym, location loc)
+grammar_current_rule_symbol_append (symbol *sym, location loc,
+ named_ref* named_ref)
{
+ symbol_list *p;
if (current_rule->action_props.code)
grammar_midrule_action ();
- grammar_symbol_append (sym, loc);
+ p = grammar_symbol_append (sym, loc);
+
+ if (named_ref)
+ {
+ if (named_ref->id == sym->tag)
+ {
+ warn_at (named_ref->loc,
+ _("duplicated symbol name for %s ignored"),
+ quote (sym->tag));
+ named_ref_free (named_ref);
+ }
+ else
+ p->named_ref = named_ref;
+ }
}
/* Attach an ACTION to the current rule. */
void
-grammar_current_rule_action_append (const char *action, location loc)
+grammar_current_rule_action_append (const char *action, location loc,
+ named_ref* named_ref)
{
if (current_rule->action_props.code)
grammar_midrule_action ();
/* After all symbol declarations have been parsed, packgram invokes
code_props_translate_code. */
code_props_rule_action_init (¤t_rule->action_props, action, loc,
- current_rule);
+ current_rule, named_ref);
}
diff --git a/src/reader.h b/src/reader.h
index 2d73ab3..3c25027 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -23,6 +23,7 @@
# include "location.h"
# include "symlist.h"
+# include "named-ref.h"
# include "parse-gram.h"
@@ -42,14 +43,14 @@ char const *token_name (int type);
/* From reader.c. */
void grammar_start_symbol_set (symbol *sym, location loc);
-void grammar_current_rule_begin (symbol *lhs, location loc);
+void grammar_current_rule_begin (symbol *lhs, location loc, named_ref* lhs_named_ref);
void grammar_current_rule_end (location loc);
void grammar_midrule_action (void);
void grammar_current_rule_prec_set (symbol *precsym, location loc);
void grammar_current_rule_dprec_set (int dprec, location loc);
void grammar_current_rule_merge_set (uniqstr name, location loc);
-void grammar_current_rule_symbol_append (symbol *sym, location loc);
-void grammar_current_rule_action_append (const char *action, location loc);
+void grammar_current_rule_symbol_append (symbol *sym, location loc, named_ref* named_ref);
+void grammar_current_rule_action_append (const char *action, location loc, named_ref* named_ref);
void reader (void);
void free_merger_functions (void);
diff --git a/src/scan-code.h b/src/scan-code.h
index a980b86..cf5b6d7 100644
--- a/src/scan-code.h
+++ b/src/scan-code.h
@@ -21,6 +21,7 @@
# define SCAN_CODE_H_
# include "location.h"
+# include "named-ref.h"
struct symbol_list;
@@ -64,6 +65,9 @@ typedef struct code_props {
/** \c NULL iff \c code_props::kind is not \c CODE_PROPS_RULE_ACTION. */
struct symbol_list *rule;
+
+ /* Named reference. */
+ named_ref *named_ref;
} code_props;
/**
@@ -76,7 +80,7 @@ void code_props_none_init (code_props *self);
/** Equivalent to \c code_props_none_init. */
#define CODE_PROPS_NONE_INIT \
- {CODE_PROPS_NONE, NULL, EMPTY_LOCATION_INIT, false, NULL}
+ {CODE_PROPS_NONE, NULL, EMPTY_LOCATION_INIT, false, NULL, NULL}
/** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */
extern code_props const code_props_none;
@@ -129,7 +133,8 @@ void code_props_symbol_action_init (code_props *self, char const *code,
* - The caller frees \c rule.
*/
void code_props_rule_action_init (code_props *self, char const *code,
- location code_loc, struct symbol_list *rule);
+ location code_loc, struct symbol_list *rule,
+ named_ref *named_ref);
/**
* \pre
diff --git a/src/scan-code.l b/src/scan-code.l
index 7a655fb..4b10d26 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -48,6 +48,10 @@ YY_DECL;
static void handle_action_dollar (symbol_list *rule, char *cp,
location dollar_loc);
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
+
+/* A string to be pushed to obstack after dollar/at has been handled */
+static char *ref_tail_fields;
+
static location the_location;
static location *loc = &the_location;
@@ -56,6 +60,7 @@ static char *last_string;
/* True if an untyped $$ or $n was seen. */
static bool untyped_var_seen;
+
%}
/* C and C++ comments in code. */
%x SC_COMMENT SC_LINE_COMMENT
@@ -75,6 +80,12 @@ tag [^\0\n>]+
white space between the backslash and the newline. */
splice (\\[ \f\t\v]*\n)*
+/* C style identifier. Must start with letter. Will be used for
+ named symbol references. */
+letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
+id {letter}({letter}|[0-9])*
+ref -?[0-9]+|{id}|"["{id}"]"|"$"
+
%%
%{
@@ -167,15 +178,22 @@ splice (\\[ \f\t\v]*\n)*
{
- "$"("<"{tag}">")?(-?[0-9]+|"$") {
+ "$"("<"{tag}">")?{ref} {
+ ref_tail_fields = 0;
handle_action_dollar (self->rule, yytext, *loc);
+ if (ref_tail_fields != NULL) {
+ obstack_sgrow (&obstack_for_string, ref_tail_fields);
+ }
need_semicolon = true;
}
- "@"(-?[0-9]+|"$") {
+ "@"{ref} {
+ ref_tail_fields = 0;
handle_action_at (self->rule, yytext, *loc);
+ if (ref_tail_fields != NULL) {
+ obstack_sgrow (&obstack_for_string, ref_tail_fields);
+ }
need_semicolon = true;
}
-
"$" {
warn_at (*loc, _("stray `$'"));
obstack_sgrow (&obstack_for_string, "$][");
@@ -267,6 +285,242 @@ splice (\\[ \f\t\v]*\n)*
%%
+
+static bool
+symbol_list_null(symbol_list *l)
+{
+ if (l && !(l->content_type == SYMLIST_SYMBOL && l->content.sym == NULL))
+ return false;
+ else
+ return true;
+}
+
+#define VARIANT_HIDDEN (1 << 0)
+#define VARIANT_BAD_BRACKETING (1 << 1)
+#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
+
+typedef struct
+{
+ uniqstr id;
+ location loc;
+ long int ind;
+ unsigned err;
+} variant;
+
+static variant *variant_table = 0;
+static unsigned variant_table_size = 0;
+static unsigned variant_count = 0;
+
+static variant *
+variant_table_grow()
+{
+ ++variant_count;
+ if (variant_count > variant_table_size)
+ {
+ while (variant_count > variant_table_size)
+ variant_table_size = 2 * variant_table_size + 3;
+ variant_table = xnrealloc (variant_table, variant_table_size,
+ sizeof *variant_table);
+ }
+ return &variant_table[variant_count - 1];
+}
+
+static char *
+find_prefix_end(const char *prefix, char *begin, char *end)
+{
+ char *ptr = begin;
+ while (*prefix && ptr != end) {
+ if (*prefix != *ptr)
+ return 0;
+ ++prefix, ++ptr;
+ }
+ if (*prefix != (char)0)
+ return 0;
+ return ptr;
+}
+
+static variant *
+variant_add(uniqstr id, location loc, long int ind,
+ char *cp, char *cp_end, bool exact_mode)
+{
+ char *prefix_end;
+
+ prefix_end = find_prefix_end(id, cp, cp_end);
+ if (prefix_end)
+ if (prefix_end == cp_end || (!exact_mode && *prefix_end == '.'))
+ {
+ variant *r = variant_table_grow();
+ r->id = id; r->loc = loc; r->ind = ind; r->err = 0;
+ if (!exact_mode && strchr(id, '.'))
+ r->err |= VARIANT_BAD_BRACKETING;
+ return r;
+ }
+
+ return NULL;
+}
+
+#define INVALID_REF (INT_MIN)
+#define LHS_REF (INT_MIN + 1)
+
+static long int
+parse_named_ref(char *cp, symbol_list *rule, int rule_length,
+ int midrule_rhs_index, char *text, location loc,
+ char dollar_or_at)
+{
+ symbol_list *l;
+ char *cp_end;
+ bool exact_mode;
+ long int ind, i;
+ variant* variant;
+ bool has_errors;
+
+ if ('$' == *cp)
+ return LHS_REF;
+
+ if (('0' <= *cp && *cp <= '9') || *cp == '-')
+ {
+ long int num = strtol (cp, &cp, 10);
+ if (1 - INT_MAX + rule_length <= num && num <= rule_length)
+ return num;
+ else
+ {
+ complain_at (loc, _("integer out of range: %s"), quote (text));
+ return INVALID_REF;
+ }
+ }
+
+ if ('[' == *cp)
+ {
+ char* p;
+ ++cp;
+ for (p = cp; *p != ']'; ++p);
+ cp_end = p;
+ exact_mode = true;
+ }
+ else
+ {
+ char* p;
+ for (p = cp; *p; ++p)
+ if ('.' == *p)
+ {
+ ref_tail_fields = p;
+ break;
+ }
+ for (p = cp; *p; ++p);
+ cp_end = p;
+ exact_mode = false;
+ }
+
+ variant_count = 0;
+
+ for (ind = 0, l = rule; !symbol_list_null(l); ++ind, l = l->next)
+ {
+ if (l->content_type != SYMLIST_SYMBOL)
+ continue;
+
+ variant = variant_add(l->content.sym->tag, l->sym_loc, ind,
+ cp, cp_end, exact_mode);
+ if (variant && l->named_ref)
+ variant->err |= VARIANT_HIDDEN;
+
+ if (l->named_ref)
+ variant_add(l->named_ref->id, l->named_ref->loc, ind,
+ cp, cp_end, exact_mode);
+ }
+
+ /* In mid-rule actions, set "not visible from midrule" error flags. */
+ if (midrule_rhs_index != 0)
+ {
+ for (i = 0; i < variant_count; ++i)
+ {
+ variant = &variant_table[i];
+ ind = variant->ind;
+ if (ind == 0 || ind > midrule_rhs_index)
+ variant->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
+ }
+ }
+
+ if (variant_count == 1 && variant_table[0].err == 0)
+ {
+ /* The only "good" case is here. */
+ ind = variant_table[0].ind;
+ if (ind == midrule_rhs_index)
+ return LHS_REF;
+ else
+ return ind;
+ }
+
+ /* Issue complains. */
+
+ if (variant_count > 1)
+ {
+ bool has_errors = false;
+ for (i = 0; i < variant_count; ++i)
+ {
+ variant = &variant_table[i];
+ if (variant->err != 0)
+ {
+ has_errors = true;
+ break;
+ }
+ }
+
+ if (has_errors)
+ complain_at (loc, _("reference is misleading: %s"), quote (text));
+ else
+ complain_at (loc, _("reference is ambiguous: %s"), quote (text));
+ }
+ else
+ complain_at (loc, _("reference not found: %s"), quote (text));
+
+ for (i = 0; i < variant_count; ++i)
+ {
+ unsigned err;
+ static char at_buf[20];
+
+ variant = &variant_table[i];
+ err = variant->err;
+
+ if (variant->ind == 0)
+ strcpy(at_buf, "$$");
+ else
+ sprintf(at_buf, "$%d", variant->ind);
+
+ if (err == 0)
+ complain_at (variant->loc, _(" refers to: %c%s at %s"),
+ dollar_or_at, variant->id, at_buf);
+ else
+ {
+ static char msg_buf[120];
+ const char *tail = "";
+ const char *lbr = "";
+ const char *rbr = "";
+
+ if (!exact_mode)
+ tail = cp + strlen(variant->id);
+
+ *msg_buf = (char)0;
+ if (err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
+ sprintf(msg_buf + strlen(msg_buf), ", cannot be accessed from "
+ "mid-rule action at $%d", midrule_rhs_index);
+ if (err & VARIANT_HIDDEN)
+ sprintf(msg_buf + strlen(msg_buf), ", symbol hidden");
+
+ if (err & VARIANT_BAD_BRACKETING || strlen(tail) > 0)
+ {
+ lbr = "["; rbr = "]";
+ }
+
+ complain_at (variant->loc, _(" possibly meant: %c%s%s%s%s at %s%s"),
+ dollar_or_at, lbr, variant->id, rbr, tail,
+ at_buf, msg_buf);
+
+ }
+ }
+
+ return INVALID_REF;
+}
+
/* Keeps track of the maximum number of semantic values to the left of
a handle (those referenced by $0, $-1, etc.) are required by the
semantic actions of this grammar. */
@@ -285,9 +539,9 @@ static void
handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
{
char const *type_name = NULL;
- char *cp = text + 1;
+ char *cp = text + 1, *gt_ptr = 0;
symbol_list *effective_rule;
- int effective_rule_length;
+ int effective_rule_length, n;
if (rule->midrule_parent_rule)
{
@@ -306,15 +560,28 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
type_name = ++cp;
while (*cp != '>')
++cp;
- *cp = '\0';
+
+ /* The '>' symbol will be later replaced by '\0'. Original
+ 'text' is needed for error messages. */
+ gt_ptr = cp;
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
tag_seen = true;
}
- if (*cp == '$')
+ n = parse_named_ref (cp, effective_rule, effective_rule_length,
+ rule->midrule_parent_rhs_index, text, dollar_loc, '$');
+
+ if (gt_ptr)
+ *gt_ptr = '\0';
+
+ switch (n)
{
+ case INVALID_REF:
+ break;
+
+ case LHS_REF:
if (!type_name)
type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0);
@@ -340,39 +607,31 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
obstack_fgrow1 (&obstack_for_string,
"]b4_lhs_value([%s])[", type_name);
rule->action_props.is_value_used = true;
- }
- else
- {
- long int num = strtol (cp, NULL, 10);
-
- if (1 - INT_MAX + effective_rule_length <= num
- && num <= effective_rule_length)
+ break;
+
+ default:
+ if (max_left_semantic_context < 1 - n)
+ max_left_semantic_context = 1 - n;
+ if (!type_name && 0 < n)
+ type_name =
+ symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
+ if (!type_name)
{
- int n = num;
- if (max_left_semantic_context < 1 - n)
- max_left_semantic_context = 1 - n;
- if (!type_name && 0 < n)
- type_name =
- symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
- if (!type_name)
- {
- if (union_seen | tag_seen)
- complain_at (dollar_loc, _("$%d of `%s' has no declared type"),
- n, effective_rule->content.sym->tag);
- else
- untyped_var_seen = true;
- type_name = "";
- }
-
- obstack_fgrow3 (&obstack_for_string,
- "]b4_rhs_value(%d, %d, [%s])[",
- effective_rule_length, n, type_name);
- if (n > 0)
- symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
- true;
+ if (union_seen | tag_seen)
+ complain_at (dollar_loc, _("$%s of `%s' has no declared type"),
+ cp, effective_rule->content.sym->tag);
+ else
+ untyped_var_seen = true;
+ type_name = "";
}
- else
- complain_at (dollar_loc, _("integer out of range: %s"), quote (text));
+
+ obstack_fgrow3 (&obstack_for_string,
+ "]b4_rhs_value(%d, %d, [%s])[",
+ effective_rule_length, n, type_name);
+ if (n > 0)
+ symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
+ true;
+ break;
}
}
@@ -386,28 +645,37 @@ static void
handle_action_at (symbol_list *rule, char *text, location at_loc)
{
char *cp = text + 1;
- int effective_rule_length =
- (rule->midrule_parent_rule
- ? rule->midrule_parent_rhs_index - 1
- : symbol_list_length (rule->next));
+ symbol_list *effective_rule;
+ int effective_rule_length, n;
+
+ if (rule->midrule_parent_rule)
+ {
+ effective_rule = rule->midrule_parent_rule;
+ effective_rule_length = rule->midrule_parent_rhs_index - 1;
+ }
+ else
+ {
+ effective_rule = rule;
+ effective_rule_length = symbol_list_length (rule->next);
+ }
locations_flag = true;
- if (*cp == '$')
- obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
- else
+ n = parse_named_ref (cp, effective_rule, effective_rule_length,
+ rule->midrule_parent_rhs_index, text, at_loc, '@');
+ switch (n)
{
- long int num = strtol (cp, NULL, 10);
+ case INVALID_REF:
+ break;
- if (1 - INT_MAX + effective_rule_length <= num
- && num <= effective_rule_length)
- {
- int n = num;
- obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
- effective_rule_length, n);
- }
- else
- complain_at (at_loc, _("integer out of range: %s"), quote (text));
+ case LHS_REF:
+ obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
+ break;
+
+ default:
+ obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
+ effective_rule_length, n);
+ break;
}
}
@@ -459,6 +727,7 @@ code_props_plain_init (code_props *self, char const *code, location code_loc)
self->location = code_loc;
self->is_value_used = false;
self->rule = NULL;
+ self->named_ref = NULL;
}
void
@@ -470,17 +739,20 @@ code_props_symbol_action_init (code_props *self, char const *code,
self->location = code_loc;
self->is_value_used = false;
self->rule = NULL;
+ self->named_ref = NULL;
}
void
code_props_rule_action_init (code_props *self, char const *code,
- location code_loc, symbol_list *rule)
+ location code_loc, symbol_list *rule,
+ named_ref *named_ref)
{
self->kind = CODE_PROPS_RULE_ACTION;
self->code = code;
self->location = code_loc;
self->is_value_used = false;
self->rule = rule;
+ self->named_ref = named_ref;
}
void
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 9a733bc..0ba30c4 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -58,6 +58,12 @@ static size_t no_cr_read (FILE *, char *, size_t);
/* A string representing the most recently saved token. */
static char *last_string;
+/* Bracketed identifier */
+static uniqstr bracketed_id_str = 0;
+static location bracketed_id_loc;
+static boundary bracketed_id_start;
+static int bracketed_id_context_state = 0;
+
void
gram_scanner_last_string_free (void)
{
@@ -90,6 +96,8 @@ static void unexpected_newline (boundary, char const *);
%x SC_COMMENT SC_LINE_COMMENT
/* Strings and characters in code. */
%x SC_STRING SC_CHARACTER
+ /* Bracketed identifiers support */
+%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
id {letter}({letter}|[0-9])*
@@ -134,7 +142,7 @@ splice (\\[ \f\t\v]*\n)*
| Scanning white space. |
`-----------------------*/
-
+
{
/* Comments and white space. */
"," warn_at (*loc, _("stray `,' treated as white space"));
@@ -273,6 +281,12 @@ splice (\\[ \f\t\v]*\n)*
return PERCENT_PERCENT;
}
+ "[" {
+ bracketed_id_start = loc->start;
+ bracketed_id_context_state = YY_START;
+ BEGIN SC_BRACKETED_ID;
+ }
+
. {
complain_at (*loc, _("invalid character: %s"), quote (yytext));
}
@@ -301,25 +315,81 @@ splice (\\[ \f\t\v]*\n)*
{
+ "[" {
+ bracketed_id_start = loc->start;
+ bracketed_id_context_state = YY_START;
+ BEGIN SC_BRACKETED_ID;
+ }
":" {
*loc = id_loc;
- BEGIN INITIAL;
+ BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL);
return ID_COLON;
}
. {
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0);
yyless (0);
*loc = id_loc;
- BEGIN INITIAL;
+ BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL);
return ID;
}
<> {
*loc = id_loc;
- BEGIN INITIAL;
+ BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL);
return ID;
}
}
+ /*--------------------------------.
+ | Scanning bracketed identifiers. |
+ `--------------------------------*/
+
+
+{
+ {id} {
+ if (!bracketed_id_str)
+ {
+ bracketed_id_str = uniqstr_new (yytext);
+ bracketed_id_loc = *loc;
+ }
+ else
+ complain_at (*loc, _("invalid characters in bracketed name: %s"), quote (yytext));
+ }
+ "]" {
+ if (bracketed_id_str)
+ {
+ BEGIN bracketed_id_context_state;
+ if (INITIAL == bracketed_id_context_state)
+ {
+ val->uniqstr = bracketed_id_str;
+ bracketed_id_str = 0;
+ *loc = bracketed_id_loc;
+ return BRACKETED_ID;
+ }
+ }
+ else
+ complain_at (*loc, _("non empty identifier expected: %s"), quote (yytext));
+ }
+ . {
+ complain_at (*loc, _("invalid character in bracketed name: %s"), quote (yytext));
+ }
+ <> {
+ unexpected_eof (bracketed_id_start, "]");
+ }
+}
+
+
+{
+ . {
+ scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0);
+ yyless (0);
+ val->uniqstr = bracketed_id_str;
+ bracketed_id_str = 0;
+ *loc = bracketed_id_loc;
+ BEGIN INITIAL;
+ return BRACKETED_ID;
+ }
+}
+
/*---------------------------------------------------------------.
| Scanning a Yacc comment. The initial `/ *' is already eaten. |
diff --git a/src/symlist.c b/src/symlist.c
index 6c6b57d..974d974 100644
--- a/src/symlist.c
+++ b/src/symlist.c
@@ -35,7 +35,7 @@ symbol_list_sym_new (symbol *sym, location loc)
res->content_type = SYMLIST_SYMBOL;
res->content.sym = sym;
- res->location = loc;
+ res->location = res->sym_loc = loc;
res->midrule = NULL;
res->midrule_parent_rule = NULL;
@@ -47,6 +47,8 @@ symbol_list_sym_new (symbol *sym, location loc)
res->dprec = 0;
res->merger = 0;
+ res->named_ref = NULL;
+
res->next = NULL;
return res;
@@ -64,7 +66,8 @@ symbol_list_type_new (uniqstr type_name, location loc)
res->content_type = SYMLIST_TYPE;
res->content.type_name = type_name;
- res->location = loc;
+ res->location = res->sym_loc = loc;
+ res->named_ref = NULL;
res->next = NULL;
return res;
@@ -81,7 +84,8 @@ symbol_list_default_tagged_new (location loc)
symbol_list *res = xmalloc (sizeof *res);
res->content_type = SYMLIST_DEFAULT_TAGGED;
- res->location = loc;
+ res->location = res->sym_loc = loc;
+ res->named_ref = NULL;
res->next = NULL;
return res;
@@ -98,7 +102,8 @@ symbol_list_default_tagless_new (location loc)
symbol_list *res = xmalloc (sizeof *res);
res->content_type = SYMLIST_DEFAULT_TAGLESS;
- res->location = loc;
+ res->location = res->sym_loc = loc;
+ res->named_ref = NULL;
res->next = NULL;
return res;
diff --git a/src/symlist.h b/src/symlist.h
index 992fd4e..df3a042 100644
--- a/src/symlist.h
+++ b/src/symlist.h
@@ -23,6 +23,7 @@
# include "location.h"
# include "scan-code.h"
# include "symtab.h"
+# include "named-ref.h"
/* A list of symbols, used during the parsing to store the rules. */
typedef struct symbol_list
@@ -48,6 +49,9 @@ typedef struct symbol_list
} content;
location location;
+ /* Proper location of the symbol, not all the rule */
+ location sym_loc;
+
/* If this symbol is the generated lhs for a midrule but this is the rule in
whose rhs it appears, MIDRULE = a pointer to that midrule. */
struct symbol_list *midrule;
@@ -69,6 +73,9 @@ typedef struct symbol_list
int merger;
location merger_declaration_location;
+ /* Named reference. */
+ named_ref *named_ref;
+
/* The list. */
struct symbol_list *next;
} symbol_list;
diff --git a/tests/named-refs.at b/tests/named-refs.at
new file mode 100644
index 0000000..15db62b
--- /dev/null
+++ b/tests/named-refs.at
@@ -0,0 +1,269 @@
+# Named references test. -*- Autotest -*-
+
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 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 .
+
+AT_BANNER([[Named references tests.]])
+
+AT_SETUP([Tutorial calculator])
+
+AT_DATA_GRAMMAR([test.y],
+[[
+%{
+#include
+#include
+#include
+#include
+typedef int semantic_value;
+FILE *input;
+static semantic_value global_result = 0;
+static int global_count = 0;
+static int power (int base, int exponent);
+static void yyerror (const char *s);
+int yylex (void);
+%}
+
+%union
+{
+ semantic_value ival;
+};
+
+%token CALC_EOF 0 "end of input"
+%token NUM "number"
+%type exp
+
+%nonassoc '=' /* comparison */
+%left '-' '+'
+%left '*' '/'
+%precedence NEG /* negation--unary minus */
+%right '^' /* exponentiation */
+
+%%
+input:
+ line
+| input line { }
+;
+
+line:
+ '\n'
+| exp '\n' { }
+;
+
+exp:
+ NUM { $$ = $NUM; }
+| exp[l] '=' exp[r]
+ {
+ if ($l != $r)
+ fprintf (stderr, "calc: error: %d != %d\n", $l, $r);
+ $$ = $l;
+ }
+| exp[x] '+' { $$ = $x; } [l] exp[r] { $$ = $l + $r; }
+| exp[l] '-' exp[r] { $$ = $l - $r; }
+| exp[l] '*' exp[r] { $$ = $l * $r; }
+| exp[l] '/' exp[r] { $$ = $l / $r; }
+| '-' exp %prec NEG { $$ = -$2; }
+| exp[l] '^' exp[r] { $$ = power ($l, $r); }
+| '(' exp[e] ')' { $$ = $e; }
+| '(' error ')' { $$ = 1111; yyerrok; }
+| '!' { $$ = 0; YYERROR; }
+| '-' error { $$ = 0; YYERROR; }
+;
+%%
+
+static void yyerror (const char *s)
+{
+ fprintf (stderr, "%s\n", s);
+}
+
+static int get_char (void)
+{
+ int res = getc (input);
+ return res;
+}
+
+static void unget_char (int c)
+{
+ ungetc (c, input);
+}
+
+static int read_signed_integer (void)
+{
+ int c = get_char ();
+ int sign = 1;
+ int n = 0;
+ if (c == '-')
+ {
+ c = get_char ();
+ sign = -1;
+ }
+ while (isdigit (c))
+ {
+ n = 10 * n + (c - '0');
+ c = get_char ();
+ }
+ unget_char ( c);
+ return sign * n;
+}
+
+int yylex (void)
+{
+ int c;
+ /* Skip white space. */
+ while ((c = get_char ()) == ' ' || c == '\t') {}
+
+ /* process numbers */
+ if (c == '.' || isdigit (c))
+ {
+ unget_char ( c);
+ (yylval).ival = read_signed_integer ();
+ return NUM;
+ }
+
+ /* Return end-of-file. */
+ if (c == EOF)
+ return CALC_EOF;
+
+ /* Return single chars. */
+ return c;
+}
+
+static int power (int base, int exponent)
+{
+ int res = 1;
+ if (exponent < 0)
+ exit (3);
+ for (/* Niente */; exponent; --exponent)
+ res *= base;
+ return res;
+}
+
+int main (int argc, const char **argv)
+{
+ semantic_value result = 0;
+ int count = 0;
+ int status;
+ if (argc == 2)
+ input = fopen (argv[1], "r");
+ else
+ input = stdin;
+ if (!input)
+ {
+ perror (argv[1]);
+ return 3;
+ }
+ status = yyparse ();
+ fclose (input);
+ if (global_result != result)
+ abort ();
+ if (global_count != count)
+ abort ();
+ return status;
+}
+]])
+
+AT_DATA([input.txt],
+[[
+1 + 2 * 3 = 7
+1 + 2 * -3 = -5
+-1^2 = -1
+(-1)^2 = 1
+---1 = -1
+1 - 2 - 3 = -4
+1 - (2 - 3) = 2
+2^2^3 = 256
+(2^2)^3 = 64
+]])
+
+AT_BISON_CHECK([-o test.c test.y])
+AT_COMPILE([[test]])
+AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
+AT_CLEANUP
+
+
+
+#######################################################################
+
+
+AT_SETUP([Undefined and ambiguous references])
+
+AT_DATA_GRAMMAR([test.y],
+[[
+%{
+static int power (int base, int exponent);
+static void yyerror (const char *s);
+int yylex (void);
+%}
+
+%union
+{
+ int ival;
+};
+
+%token CALC_EOF 0 "end of input"
+%token NUM "number"
+%type exp
+
+%nonassoc '=' /* comparison */
+%left '-' '+'
+%left '*' '/'
+%precedence NEG /* negation--unary minus */
+%right '^' /* exponentiation */
+
+%%
+input:
+ line
+| input line { }
+;
+
+line:
+ '\n'
+| exp '\n' { }
+;
+
+exp:
+ NUM { $$ = $NUM; }
+| exp[l] '=' exp[r]
+ {
+ if ($l != $r)
+ fprintf (stderr, "calc: error: %d != %d\n", $l, $r);
+ $$ = $l;
+ }
+| exp[x] '+' { $$ = $x; } [l] exp[r] { $$ = $lo9 + $r; }
+| exp[x] '-' { $$ = $x; } [l] exp[r] { $$ = $exp - $r; }
+| exp[x] '*' { $$ = $x; } [l] exp[r] { $$ = $l * $r; }
+| exp[l] '/' exp[r] { $$ = $l / $r; }
+| '-' exp %prec NEG { $$ = -$2; }
+| exp[l] '^' exp[r] { $$ = power ($l, $r12); }
+| '(' exp ')' { $$ = $expo; }
+| '(' error ')' { $$ = 1111; yyerrok; }
+| '!' { $$ = 0; YYERROR; }
+| '-' error { $$ = 0; YYERROR; }
+;
+%%
+]])
+
+AT_BISON_CHECK([-o test.c test.y], 1, [],
+[[test.y:50.51-60: reference not found: `$lo9'
+test.y:51.51-60: reference is misleading: `$exp'
+test.y:42.1-3: refers to: $exp at $$
+test.y:51.3-5: possibly meant: $exp at $1, symbol hidden
+test.y:51.37-39: possibly meant: $exp at $4, symbol hidden
+test.y:52.51-52: $l of `exp' has no declared type
+test.y:55.46-49: reference not found: `$r12'
+test.y:56.29-33: reference not found: `$expo'
+]])
+AT_CLEANUP
+
diff --git a/tests/testsuite.at b/tests/testsuite.at
index fa7d748..ebf2532 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -23,6 +23,9 @@ m4_include([input.at])
# Testing output file names.
m4_include([output.at])
+# Push parsing specific tests.
+m4_include([named-refs.at])
+
# Testing skeleton support.
m4_include([skeletons.at])
@@ -66,8 +69,10 @@ m4_include([java.at])
# GLR tests:
# C++ types, simplified
m4_include([cxx-type.at])
+
# Regression tests
m4_include([glr-regression.at])
# Push parsing specific tests.
m4_include([push.at])
+
--
1.6.0.6