string_to_symbol,
name_to_tag
):
- assert pyacc.initial_action_code is None
- pyacc.initial_action_code = self[0]
+ pyacc.initial_action_code.append(self[0])
class Language(Item):
# GENERATE ELEMENT() BEGIN
):
pass
- # GENERATE ELEMENT(list(ref) top_code, list(ref) before_union_code, list(ref) requires_code, str union_name, list(ref) union_code, list(ref) after_union_code, ref initial_action_code, list(ref) tags, list(ref) symbols, int n_productions, list(ref) productions, int first_nonterminal, int start_nonterminal, list(int) associativities) BEGIN
+ # GENERATE ELEMENT(list(ref) top_code, list(ref) before_union_code, list(ref) requires_code, str union_name, list(ref) union_code, list(ref) after_union_code, list(ref) initial_action_code, list(ref) tags, list(ref) symbols, int n_productions, list(ref) productions, int first_nonterminal, int start_nonterminal, list(int) associativities) BEGIN
def __init__(
self,
tag = 'PYACC',
union_name = '',
union_code = [],
after_union_code = [],
- initial_action_code = None,
+ initial_action_code = [],
tags = [],
symbols = [],
n_productions = -1,
'after_union_code',
' '.join([element.serialize_ref(i, ref_list) for i in self.after_union_code])
)
- self.set('initial_action_code', element.serialize_ref(self.initial_action_code, ref_list))
+ self.set(
+ 'initial_action_code',
+ ' '.join([element.serialize_ref(i, ref_list) for i in self.initial_action_code])
+ )
self.set(
'tags',
' '.join([element.serialize_ref(i, ref_list) for i in self.tags])
element.deserialize_ref(i, ref_list)
for i in self.get('after_union_code', '').split()
]
- self.initial_action_code = element.deserialize_ref(self.get('initial_action_code', '-1'), ref_list)
+ self.initial_action_code = [
+ element.deserialize_ref(i, ref_list)
+ for i in self.get('initial_action_code', '').split()
+ ]
self.tags = [
element.deserialize_ref(i, ref_list)
for i in self.get('tags', '').split()
', '.join([repr(i) for i in self.after_union_code])
)
)
- if self.initial_action_code != None:
+ if len(self.initial_action_code):
params.append(
- 'initial_action_code = {0:s}'.format(repr(self.initial_action_code))
+ 'initial_action_code = [{0:s}]'.format(
+ ', '.join([repr(i) for i in self.initial_action_code])
+ )
)
if len(self.tags):
params.append(
self.union_name = ''
self.union_code = []
self.after_union_code = []
- self.initial_action_code = None
+ self.initial_action_code = []
self.precedences = 0
self.symbols = [
PYACC.Symbol(
---- y.tab.c.orig 2018-07-29 21:31:56.731898662 +1000
-+++ y.tab.c 2018-07-29 21:34:16.699902356 +1000
+--- y.tab.c.orig 2018-07-30 07:49:37.272876744 +1000
++++ y.tab.c 2018-07-30 08:33:25.532946107 +1000
@@ -50,7 +50,7 @@
#define YYSKELETON_NAME "yacc.c"
-union YYSTYPE
-{
- /* something */
--
--};
+/* GENERATE SECTION1REQUIRES */
+-};
+-
-typedef union YYSTYPE YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define YYSTYPE_IS_DECLARED 1
-#endif
+# if (defined YYLTYPE || defined YYLTYPE_IS_DECLARED) \
+ && defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
-+
+
+/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
-+
+
+-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+YY_ATTRIBUTE_UNUSED
+static unsigned
+yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
+ }
+ return res;
+ }
-
++
+# define YY_LOCATION_PRINT(File, Loc) \
+ yy_location_print_ (File, &(Loc))
-
--# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
++
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
-@@ -1075,6 +1153,9 @@
+@@ -1009,6 +1087,13 @@
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
++
++/* User initialization code. */
++/* GENERATE INITIALACTION */
++
++#if defined YYLTYPE || defined YYLTYPE_IS_DECLARED
++ yylsp[0] = yylloc;
++#endif
+ goto yysetstate;
+
+ /*------------------------------------------------------------.
+@@ -1034,16 +1119,29 @@
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
++#if defined YYLTYPE || defined YYLTYPE_IS_DECLARED
++ YYLTYPE *yyls1 = yyls;
++#endif
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
++#if defined YYLTYPE || defined YYLTYPE_IS_DECLARED
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
++ &yyls1, yysize * sizeof (*yylsp),
+ &yystacksize);
+
++ yyls = yyls1;
++#else
++ yyoverflow (YY_("memory exhausted"),
++ &yyss1, yysize * sizeof (*yyssp),
++ &yyvs1, yysize * sizeof (*yyvsp),
++ &yystacksize);
++
++#endif
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+@@ -1066,6 +1164,9 @@
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
++#if defined YYLTYPE || defined YYLTYPE_IS_DECLARED
++ YYSTACK_RELOCATE (yyls_alloc, yyls);
++#endif
+ # undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+@@ -1075,6 +1176,9 @@
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
-@@ -1109,7 +1190,15 @@
+@@ -1109,7 +1213,15 @@
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
}
if (yychar <= YYEOF)
-@@ -1152,7 +1241,9 @@
+@@ -1152,7 +1264,9 @@
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
goto yynewstate;
-@@ -1183,18 +1274,14 @@
+@@ -1183,18 +1297,14 @@
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
default: break;
}
-@@ -1216,6 +1303,9 @@
+@@ -1216,6 +1326,9 @@
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
-@@ -1245,7 +1335,11 @@
+@@ -1245,7 +1358,11 @@
{
++yynerrs;
#if ! YYERROR_VERBOSE
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
-@@ -1272,7 +1366,11 @@
+@@ -1272,7 +1389,11 @@
yymsgp = yymsg;
}
}
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
-@@ -1280,7 +1378,9 @@
+@@ -1280,7 +1401,9 @@
#endif
}
if (yyerrstatus == 3)
{
-@@ -1295,8 +1395,13 @@
+@@ -1295,8 +1418,13 @@
}
else
{
yychar = YYEMPTY;
}
}
-@@ -1317,6 +1422,9 @@
+@@ -1317,6 +1445,9 @@
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
-@@ -1350,9 +1458,14 @@
+@@ -1350,9 +1481,14 @@
if (yyssp == yyss)
YYABORT;
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
-@@ -1362,6 +1475,13 @@
+@@ -1362,6 +1498,13 @@
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-@@ -1389,7 +1509,11 @@
+@@ -1389,7 +1532,11 @@
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyresult = 2;
/* Fall through. */
#endif
-@@ -1400,8 +1524,13 @@
+@@ -1400,8 +1547,13 @@
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
-@@ -1409,8 +1538,13 @@
+@@ -1409,8 +1561,13 @@
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
YYPOPSTACK (1);
}
#ifndef yyoverflow
-@@ -1423,3 +1557,5 @@
+@@ -1423,3 +1580,5 @@
#endif
return yyresult;
}