if name == 'api.prefix':
section.api_prefix = value
elif name == 'api.pure':
- section.api_pure = value
+ if value == 'full':
+ section.api_pure = 2
+ elif value == '' or value == 'true':
+ section.api_pure = 1
+ elif value == 'false':
+ section.api_pure = 0
+ else:
+ assert False
elif name == 'locations':
- assert value == '' or value == 'true' or value == 'false'
- section.locations = value != 'false'
+ if value == '' or value == 'true':
+ section.locations = True
+ elif value == 'false':
+ section.locations = False
+ else:
+ assert False
elif name == 'parse.error':
section.parse_error = value
elif name == 'parse.lac':
section.parse_lac = value
elif name == 'parse.trace':
- assert value == '' or value == 'true' or value == 'false'
- section.parse_trace = value != 'false'
+ if value == '' or value == 'true':
+ section.parse_trace = True
+ elif value == 'false':
+ section.parse_trace = False
+ else:
+ assert False
else:
assert False
return 'ast.PYACC.Section1.YACC({0:s})'.format(', '.join(params))
# GENERATE END
- # GENERATE ELEMENT(str api_prefix, str api_pure, bool locations, str parse_error, str parse_lac, bool parse_trace, bool defines, int expect, bool verbose) BEGIN
+ # GENERATE ELEMENT(str api_prefix, int api_pure, bool locations, str parse_error, str parse_lac, bool parse_trace, bool defines, int expect, bool verbose) BEGIN
def __init__(
self,
tag = 'PYACC_Section1',
text = '',
children = [],
api_prefix = '',
- api_pure = '',
+ api_pure = -1,
locations = False,
parse_error = '',
parse_lac = '',
children
)
self.api_prefix = api_prefix
- self.api_pure = api_pure
+ self.api_pure = (
+ element.deserialize_int(api_pure)
+ if isinstance(api_pure, str) else
+ api_pure
+ )
self.locations = (
element.deserialize_bool(locations)
if isinstance(locations, str) else
def serialize(self, ref_list):
PYACC.Section1Or2.serialize(self, ref_list)
self.set('api_prefix', element.serialize_str(self.api_prefix))
- self.set('api_pure', element.serialize_str(self.api_pure))
+ self.set('api_pure', element.serialize_int(self.api_pure))
self.set('locations', element.serialize_bool(self.locations))
self.set('parse_error', element.serialize_str(self.parse_error))
self.set('parse_lac', element.serialize_str(self.parse_lac))
def deserialize(self, ref_list):
PYACC.Section1Or2.deserialize(self, ref_list)
self.api_prefix = element.deserialize_str(self.get('api_prefix', ''))
- self.api_pure = element.deserialize_str(self.get('api_pure', ''))
+ self.api_pure = element.deserialize_int(self.get('api_pure', '-1'))
self.locations = element.deserialize_bool(self.get('locations', 'false'))
self.parse_error = element.deserialize_str(self.get('parse_error', ''))
self.parse_lac = element.deserialize_str(self.get('parse_lac', ''))
params.append(
'api_prefix = {0:s}'.format(repr(self.api_prefix))
)
- if self.api_pure != '':
+ if self.api_pure != -1:
params.append(
'api_pure = {0:s}'.format(repr(self.api_pure))
)
name_to_tag
):
self.api_prefix = ''
- self.api_pure = ''
+ self.api_pure = 0
self.locations = False
self.parse_error = ''
self.parse_lac = ''
)
if len(self.api_prefix):
sys.stderr.write('warning: ignoring %define api.prefix\n')
- if len(self.api_pure):
- sys.stderr.write('warning: ignoring %define api.pure\n')
+ #if self.api_pure != 0:
+ # sys.stderr.write('warning: ignoring %define api.pure\n')
if self.locations:
sys.stderr.write('warning: ignoring %define locations\n')
if len(self.parse_error):
---- y.tab.c.orig 2018-07-26 21:54:50.154480530 +1000
-+++ y.tab.c 2018-07-26 22:00:46.558496008 +1000
+--- y.tab.c.orig 2018-07-29 17:18:39.855497595 +1000
++++ y.tab.c 2018-07-29 17:18:53.715497961 +1000
+@@ -50,7 +50,7 @@
+ #define YYSKELETON_NAME "yacc.c"
+
+ /* Pure parsers. */
+-#define YYPURE 0
++/* GENERATE YYPURE */
+
+ /* Push parsers. */
+ #define YYPUSH 0
@@ -58,11 +58,11 @@
/* Pull parsers. */
#define YYPULL 1
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
-@@ -97,22 +97,17 @@
+@@ -97,28 +97,24 @@
# define YYTOKENTYPE
enum yytokentype
{
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
-@@ -126,6 +121,7 @@
+
+-
++#if !YYPURE
+ extern YYSTYPE yylval;
++#endif
+
+ int yyparse (void);
+
+@@ -126,6 +122,7 @@
/* Copy the second part of user declarations. */
#ifdef short
# undef short
-@@ -364,155 +360,7 @@
+@@ -364,155 +361,7 @@
# endif
#endif /* !YYCOPY_NEEDED */
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
-@@ -1187,14 +1035,7 @@
+@@ -936,9 +785,7 @@
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+ }
+
+-
+-
+-
++#if !YYPURE
+ /* The lookahead symbol. */
+ int yychar;
+
+@@ -946,7 +793,7 @@
+ YYSTYPE yylval;
+ /* Number of syntax errors so far. */
+ int yynerrs;
+-
++#endif
+
+ /*----------.
+ | yyparse. |
+@@ -955,6 +802,20 @@
+ int
+ yyparse (void)
+ {
++#if YYPURE
++ /* The lookahead symbol. */
++ int yychar;
++
++ /* The semantic value of the lookahead symbol. */
++ /* Default value used for initialization, for pacifying older GCCs
++ or non-GCC compilers. */
++ YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
++ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
++
++ /* Number of syntax errors so far. */
++ int yynerrs;
++#endif
++
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+@@ -1109,7 +970,11 @@
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
++#if YYPURE
++ yychar = yylex (&yylval);
++#else
+ yychar = yylex ();
++#endif
+ }
+
+ if (yychar <= YYEOF)
+@@ -1187,14 +1052,7 @@
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
default: break;
}
-@@ -1423,3 +1264,5 @@
+@@ -1423,3 +1281,5 @@
#endif
return yyresult;
}