summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2020-06-22 22:42:20 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2020-06-22 22:42:20 +0000
commit5dd99b746d26517ef72ee914e30ece2761079321 (patch)
tree30d932dc7c9813aee58587bffceac1350e1ff900 /test
parent8bb3d1b8fb77d3704e1de225c83b8b66ca673da8 (diff)
Notes
Diffstat (limited to 'test')
-rw-r--r--test/btyacc/big_b.error19
-rw-r--r--test/btyacc/big_b.output18
-rw-r--r--test/btyacc/big_l.error19
-rw-r--r--test/btyacc/big_l.output18
-rw-r--r--test/btyacc/btyacc_calc1.tab.c51
-rw-r--r--test/btyacc/btyacc_calc1.tab.h1
-rw-r--r--test/btyacc/btyacc_demo.tab.c163
-rw-r--r--test/btyacc/btyacc_demo.tab.h1
-rw-r--r--test/btyacc/btyacc_demo2.error1
-rw-r--r--test/btyacc/btyacc_demo2.tab.c15
-rw-r--r--test/btyacc/btyacc_destroy1.tab.c53
-rw-r--r--test/btyacc/btyacc_destroy2.tab.c53
-rw-r--r--test/btyacc/btyacc_destroy3.tab.c53
-rw-r--r--test/btyacc/calc.tab.c51
-rw-r--r--test/btyacc/calc1.tab.c51
-rw-r--r--test/btyacc/calc2.tab.c51
-rw-r--r--test/btyacc/calc3.tab.c51
-rw-r--r--test/btyacc/calc_code_all.error (renamed from test/btyacc/btyacc_demo2.output)0
-rw-r--r--test/btyacc/calc_code_all.output485
-rw-r--r--test/btyacc/calc_code_all.tab.c1502
-rw-r--r--test/btyacc/calc_code_all.tab.h18
-rw-r--r--test/btyacc/calc_code_default.error (renamed from test/btyacc/btyacc_demo2.tab.h)0
-rw-r--r--test/btyacc/calc_code_default.output485
-rw-r--r--test/btyacc/calc_code_default.tab.c1482
-rw-r--r--test/btyacc/calc_code_default.tab.h8
-rw-r--r--test/btyacc/calc_code_imports.error (renamed from test/btyacc/code_debug.error)0
-rw-r--r--test/btyacc/calc_code_imports.output485
-rw-r--r--test/btyacc/calc_code_imports.tab.c1474
-rw-r--r--test/btyacc/calc_code_imports.tab.h8
-rw-r--r--test/btyacc/calc_code_provides.error0
-rw-r--r--test/btyacc/calc_code_provides.output485
-rw-r--r--test/btyacc/calc_code_provides.tab.c1482
-rw-r--r--test/btyacc/calc_code_provides.tab.h14
-rw-r--r--test/btyacc/calc_code_requires.error0
-rw-r--r--test/btyacc/calc_code_requires.output485
-rw-r--r--test/btyacc/calc_code_requires.tab.c1482
-rw-r--r--test/btyacc/calc_code_requires.tab.h14
-rw-r--r--test/btyacc/calc_code_top.error0
-rw-r--r--test/btyacc/calc_code_top.output485
-rw-r--r--test/btyacc/calc_code_top.tab.c1482
-rw-r--r--test/btyacc/calc_code_top.tab.h8
-rw-r--r--test/btyacc/code_calc.code.c51
-rw-r--r--test/btyacc/code_debug.i60
-rw-r--r--test/btyacc/code_debug.output34
-rw-r--r--test/btyacc/code_error.code.c49
-rw-r--r--test/btyacc/defines1.calc.c (renamed from test/btyacc/code_debug.c)466
-rw-r--r--test/btyacc/defines1.calc.h (renamed from test/btyacc/code_debug.h)4
-rw-r--r--test/btyacc/defines1.error0
-rw-r--r--test/btyacc/defines1.output0
-rw-r--r--test/btyacc/defines2.calc.c1381
-rw-r--r--test/btyacc/defines2.calc.h8
-rw-r--r--test/btyacc/defines2.error0
-rw-r--r--test/btyacc/defines2.output0
-rw-r--r--test/btyacc/defines3.calc.c1381
-rw-r--r--test/btyacc/defines3.calc.h8
-rw-r--r--test/btyacc/defines3.error0
-rw-r--r--test/btyacc/defines3.output0
-rw-r--r--test/btyacc/empty.tab.c49
-rw-r--r--test/btyacc/err_inherit3.tab.c57
-rw-r--r--test/btyacc/err_inherit4.tab.c57
-rw-r--r--test/btyacc/err_inherit4.tab.h1
-rw-r--r--test/btyacc/err_syntax10.tab.c49
-rw-r--r--test/btyacc/err_syntax11.tab.c49
-rw-r--r--test/btyacc/err_syntax12.tab.c49
-rw-r--r--test/btyacc/err_syntax18.tab.c51
-rw-r--r--test/btyacc/err_syntax20.tab.c51
-rw-r--r--test/btyacc/error.tab.c49
-rw-r--r--test/btyacc/expr.oxout.tab.c51
-rw-r--r--test/btyacc/grammar.tab.c254
-rw-r--r--test/btyacc/help.error20
-rw-r--r--test/btyacc/help.output18
-rw-r--r--test/btyacc/inherit0.tab.c51
-rw-r--r--test/btyacc/inherit1.tab.c51
-rw-r--r--test/btyacc/inherit2.tab.c57
-rw-r--r--test/btyacc/no_b_opt.error20
-rw-r--r--test/btyacc/no_b_opt.output18
-rw-r--r--test/btyacc/no_b_opt1.error1
-rw-r--r--test/btyacc/no_b_opt1.output1
-rw-r--r--test/btyacc/no_code_c.error1
-rw-r--r--test/btyacc/no_code_c.output1
-rw-r--r--test/btyacc/no_defines.error1
-rw-r--r--test/btyacc/no_defines.output1
-rw-r--r--test/btyacc/no_graph.error1
-rw-r--r--test/btyacc/no_graph.output1
-rw-r--r--test/btyacc/no_include.error1
-rw-r--r--test/btyacc/no_include.output1
-rw-r--r--test/btyacc/no_opts.error1
-rw-r--r--test/btyacc/no_opts.output1
-rw-r--r--test/btyacc/no_output.error1
-rw-r--r--test/btyacc/no_output.output1
-rw-r--r--test/btyacc/no_output1.error1
-rw-r--r--test/btyacc/no_output1.output1
-rw-r--r--test/btyacc/no_output2.error20
-rw-r--r--test/btyacc/no_output2.output18
-rw-r--r--test/btyacc/no_p_opt.error20
-rw-r--r--test/btyacc/no_p_opt.output18
-rw-r--r--test/btyacc/no_p_opt1.error1
-rw-r--r--test/btyacc/no_p_opt1.output1
-rw-r--r--test/btyacc/no_verbose.error1
-rw-r--r--test/btyacc/no_verbose.output1
-rw-r--r--test/btyacc/nostdin.error19
-rw-r--r--test/btyacc/nostdin.output18
-rw-r--r--test/btyacc/ok_syntax1.tab.c51
-rw-r--r--test/btyacc/ok_syntax1.tab.h1
-rw-r--r--test/btyacc/pure_calc.tab.c51
-rw-r--r--test/btyacc/pure_error.tab.c49
-rw-r--r--test/btyacc/quote_calc-s.tab.c51
-rw-r--r--test/btyacc/quote_calc.tab.c51
-rw-r--r--test/btyacc/quote_calc2-s.tab.c51
-rw-r--r--test/btyacc/quote_calc2.tab.c51
-rw-r--r--test/btyacc/quote_calc3-s.tab.c51
-rw-r--r--test/btyacc/quote_calc3.tab.c51
-rw-r--r--test/btyacc/quote_calc4-s.tab.c51
-rw-r--r--test/btyacc/quote_calc4.tab.c51
-rw-r--r--test/btyacc/rename_debug.c49
-rw-r--r--test/btyacc/rename_debug.i13
-rw-r--r--test/btyacc/stdin1.calc.c1381
-rw-r--r--test/btyacc/stdin1.error0
-rw-r--r--test/btyacc/stdin1.output0
-rw-r--r--test/btyacc/stdin2.calc.c1381
-rw-r--r--test/btyacc/stdin2.error0
-rw-r--r--test/btyacc/stdin2.output0
-rw-r--r--test/btyacc/varsyntax_calc1.tab.c51
-rw-r--r--test/calc.tab.c668
-rw-r--r--test/calc_code_all.y113
-rw-r--r--test/calc_code_default.y109
-rw-r--r--test/calc_code_imports.y109
-rw-r--r--test/calc_code_provides.y109
-rw-r--r--test/calc_code_requires.y109
-rw-r--r--test/calc_code_top.y109
-rw-r--r--test/grammar.y37
-rwxr-xr-xtest/run_make.sh20
-rwxr-xr-xtest/run_test.sh68
-rw-r--r--test/yacc/big_b.error20
-rw-r--r--test/yacc/big_b.output19
-rw-r--r--test/yacc/big_l.error20
-rw-r--r--test/yacc/big_l.output19
-rw-r--r--test/yacc/calc.tab.c8
-rw-r--r--test/yacc/calc1.tab.c8
-rw-r--r--test/yacc/calc2.tab.c8
-rw-r--r--test/yacc/calc3.tab.c8
-rw-r--r--test/yacc/calc_code_all.error0
-rw-r--r--test/yacc/calc_code_all.output461
-rw-r--r--test/yacc/calc_code_all.tab.c699
-rw-r--r--test/yacc/calc_code_all.tab.h13
-rw-r--r--test/yacc/calc_code_default.error0
-rw-r--r--test/yacc/calc_code_default.output461
-rw-r--r--test/yacc/calc_code_default.tab.c679
-rw-r--r--test/yacc/calc_code_default.tab.h3
-rw-r--r--test/yacc/calc_code_imports.error0
-rw-r--r--test/yacc/calc_code_imports.output461
-rw-r--r--test/yacc/calc_code_imports.tab.c671
-rw-r--r--test/yacc/calc_code_imports.tab.h3
-rw-r--r--test/yacc/calc_code_provides.error0
-rw-r--r--test/yacc/calc_code_provides.output461
-rw-r--r--test/yacc/calc_code_provides.tab.c679
-rw-r--r--test/yacc/calc_code_provides.tab.h9
-rw-r--r--test/yacc/calc_code_requires.error0
-rw-r--r--test/yacc/calc_code_requires.output461
-rw-r--r--test/yacc/calc_code_requires.tab.c679
-rw-r--r--test/yacc/calc_code_requires.tab.h9
-rw-r--r--test/yacc/calc_code_top.error0
-rw-r--r--test/yacc/calc_code_top.output461
-rw-r--r--test/yacc/calc_code_top.tab.c679
-rw-r--r--test/yacc/calc_code_top.tab.h3
-rw-r--r--test/yacc/code_calc.code.c8
-rw-r--r--test/yacc/code_error.code.c6
-rw-r--r--test/yacc/defines1.calc.c595
-rw-r--r--test/yacc/defines1.calc.h3
-rw-r--r--test/yacc/defines1.error0
-rw-r--r--test/yacc/defines1.output0
-rw-r--r--test/yacc/defines2.calc.c595
-rw-r--r--test/yacc/defines2.calc.h3
-rw-r--r--test/yacc/defines2.error0
-rw-r--r--test/yacc/defines2.output0
-rw-r--r--test/yacc/defines3.calc.c595
-rw-r--r--test/yacc/defines3.calc.h3
-rw-r--r--test/yacc/defines3.error0
-rw-r--r--test/yacc/defines3.output0
-rw-r--r--test/yacc/empty.tab.c6
-rw-r--r--test/yacc/err_syntax10.tab.c6
-rw-r--r--test/yacc/err_syntax11.tab.c6
-rw-r--r--test/yacc/err_syntax12.tab.c6
-rw-r--r--test/yacc/err_syntax18.tab.c8
-rw-r--r--test/yacc/err_syntax20.tab.c8
-rw-r--r--test/yacc/error.tab.c6
-rw-r--r--test/yacc/expr.oxout.tab.c8
-rw-r--r--test/yacc/grammar.tab.c211
-rw-r--r--test/yacc/help.error20
-rw-r--r--test/yacc/help.output18
-rw-r--r--test/yacc/no_b_opt.error20
-rw-r--r--test/yacc/no_b_opt.output18
-rw-r--r--test/yacc/no_b_opt1.error1
-rw-r--r--test/yacc/no_b_opt1.output1
-rw-r--r--test/yacc/no_code_c.error1
-rw-r--r--test/yacc/no_code_c.output1
-rw-r--r--test/yacc/no_defines.error1
-rw-r--r--test/yacc/no_defines.output1
-rw-r--r--test/yacc/no_graph.error1
-rw-r--r--test/yacc/no_graph.output1
-rw-r--r--test/yacc/no_include.error1
-rw-r--r--test/yacc/no_include.output1
-rw-r--r--test/yacc/no_opts.error1
-rw-r--r--test/yacc/no_opts.output1
-rw-r--r--test/yacc/no_output.error1
-rw-r--r--test/yacc/no_output.output1
-rw-r--r--test/yacc/no_output1.error1
-rw-r--r--test/yacc/no_output1.output1
-rw-r--r--test/yacc/no_output2.error20
-rw-r--r--test/yacc/no_output2.output18
-rw-r--r--test/yacc/no_p_opt.error20
-rw-r--r--test/yacc/no_p_opt.output18
-rw-r--r--test/yacc/no_p_opt1.error1
-rw-r--r--test/yacc/no_p_opt1.output1
-rw-r--r--test/yacc/no_verbose.error1
-rw-r--r--test/yacc/no_verbose.output1
-rw-r--r--test/yacc/nostdin.error19
-rw-r--r--test/yacc/nostdin.output18
-rw-r--r--test/yacc/ok_syntax1.tab.c8
-rw-r--r--test/yacc/ok_syntax1.tab.h1
-rw-r--r--test/yacc/pure_calc.tab.c8
-rw-r--r--test/yacc/pure_error.tab.c6
-rw-r--r--test/yacc/quote_calc-s.tab.c8
-rw-r--r--test/yacc/quote_calc.tab.c8
-rw-r--r--test/yacc/quote_calc2-s.tab.c8
-rw-r--r--test/yacc/quote_calc2.tab.c8
-rw-r--r--test/yacc/quote_calc3-s.tab.c8
-rw-r--r--test/yacc/quote_calc3.tab.c8
-rw-r--r--test/yacc/quote_calc4-s.tab.c8
-rw-r--r--test/yacc/quote_calc4.tab.c8
-rw-r--r--test/yacc/rename_debug.c6
-rw-r--r--test/yacc/rename_debug.i12
-rw-r--r--test/yacc/stdin1.calc.c595
-rw-r--r--test/yacc/stdin1.error0
-rw-r--r--test/yacc/stdin1.output0
-rw-r--r--test/yacc/stdin2.calc.c595
-rw-r--r--test/yacc/stdin2.error0
-rw-r--r--test/yacc/stdin2.output0
-rw-r--r--test/yacc/varsyntax_calc1.tab.c8
239 files changed, 30831 insertions, 1772 deletions
diff --git a/test/btyacc/big_b.error b/test/btyacc/big_b.error
index e69de29bb2d1d..67101620d2c1e 100644
--- a/test/btyacc/big_b.error
+++ b/test/btyacc/big_b.error
@@ -0,0 +1,19 @@
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/btyacc/big_b.output b/test/btyacc/big_b.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/btyacc/big_b.output
+++ b/test/btyacc/big_b.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/btyacc/big_l.error b/test/btyacc/big_l.error
index e69de29bb2d1d..67101620d2c1e 100644
--- a/test/btyacc/big_l.error
+++ b/test/btyacc/big_l.error
@@ -0,0 +1,19 @@
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/btyacc/big_l.output b/test/btyacc/big_l.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/btyacc/big_l.output
+++ b/test/btyacc/big_l.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/btyacc/btyacc_calc1.tab.c b/test/btyacc/btyacc_calc1.tab.c
index 6142a131ca372..39290121ca113 100644
--- a/test/btyacc/btyacc_calc1.tab.c
+++ b/test/btyacc/btyacc_calc1.tab.c
@@ -389,8 +389,9 @@ static const char *const calc1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
#ifndef YYLLOC_DEFAULT
@@ -399,17 +400,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -615,7 +616,7 @@ vdiv(double a, double b, INTERVAL v)
{
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
}
-#line 619 "btyacc_calc1.tab.c"
+#line 620 "btyacc_calc1.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -752,6 +753,8 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -804,7 +807,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -880,10 +883,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -994,7 +997,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1204,7 +1207,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1233,7 +1236,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1249,7 +1252,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1335,10 +1338,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1537,7 +1540,7 @@ case 28:
yyval.vval = yystack.l_mark[-1].vval;
}
break;
-#line 1541 "btyacc_calc1.tab.c"
+#line 1544 "btyacc_calc1.tab.c"
default:
break;
}
@@ -1592,12 +1595,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/btyacc_calc1.tab.h b/test/btyacc/btyacc_calc1.tab.h
index 1802350b0d2ae..9cf4e75ba38a6 100644
--- a/test/btyacc/btyacc_calc1.tab.h
+++ b/test/btyacc/btyacc_calc1.tab.h
@@ -18,6 +18,5 @@ typedef union
INTERVAL vval;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
-extern YYSTYPE calc1_lval;
#endif /* _calc1__defines_h_ */
diff --git a/test/btyacc/btyacc_demo.tab.c b/test/btyacc/btyacc_demo.tab.c
index eff738cfd5b20..cdffc079ececa 100644
--- a/test/btyacc/btyacc_demo.tab.c
+++ b/test/btyacc/btyacc_demo.tab.c
@@ -508,13 +508,16 @@ static const char *const demo_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -527,17 +530,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -660,7 +663,7 @@ extern Expr * var_expr(Scope *scope, char *id);
extern Code * build_expr_code(Expr *expr);
extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);
extern Code * code_append(Code *stmt_list, Code *stmt);
-#line 664 "btyacc_demo.tab.c"
+#line 667 "btyacc_demo.tab.c"
/* Release memory associated with symbol. */
#if ! defined YYDESTRUCT_IS_DECLARED
@@ -677,7 +680,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 681 "btyacc_demo.tab.c"
+#line 684 "btyacc_demo.tab.c"
case 45:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -686,7 +689,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 690 "btyacc_demo.tab.c"
+#line 693 "btyacc_demo.tab.c"
case 42:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -695,7 +698,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 699 "btyacc_demo.tab.c"
+#line 702 "btyacc_demo.tab.c"
case 47:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -704,7 +707,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 708 "btyacc_demo.tab.c"
+#line 711 "btyacc_demo.tab.c"
case 37:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -713,7 +716,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 717 "btyacc_demo.tab.c"
+#line 720 "btyacc_demo.tab.c"
case 257:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -722,7 +725,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 726 "btyacc_demo.tab.c"
+#line 729 "btyacc_demo.tab.c"
case 258:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -731,7 +734,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 735 "btyacc_demo.tab.c"
+#line 738 "btyacc_demo.tab.c"
case 40:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -740,7 +743,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 744 "btyacc_demo.tab.c"
+#line 747 "btyacc_demo.tab.c"
case 91:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -749,7 +752,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 753 "btyacc_demo.tab.c"
+#line 756 "btyacc_demo.tab.c"
case 46:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -758,7 +761,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 762 "btyacc_demo.tab.c"
+#line 765 "btyacc_demo.tab.c"
case 259:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -767,7 +770,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).id); }
break;
-#line 771 "btyacc_demo.tab.c"
+#line 774 "btyacc_demo.tab.c"
case 260:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -776,7 +779,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).expr); }
break;
-#line 780 "btyacc_demo.tab.c"
+#line 783 "btyacc_demo.tab.c"
case 261:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -785,7 +788,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 789 "btyacc_demo.tab.c"
+#line 792 "btyacc_demo.tab.c"
case 262:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -794,7 +797,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 798 "btyacc_demo.tab.c"
+#line 801 "btyacc_demo.tab.c"
case 263:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -803,7 +806,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 807 "btyacc_demo.tab.c"
+#line 810 "btyacc_demo.tab.c"
case 264:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -812,7 +815,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 816 "btyacc_demo.tab.c"
+#line 819 "btyacc_demo.tab.c"
case 265:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -821,7 +824,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 825 "btyacc_demo.tab.c"
+#line 828 "btyacc_demo.tab.c"
case 266:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -830,7 +833,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 834 "btyacc_demo.tab.c"
+#line 837 "btyacc_demo.tab.c"
case 267:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -839,7 +842,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 843 "btyacc_demo.tab.c"
+#line 846 "btyacc_demo.tab.c"
case 268:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -848,7 +851,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 852 "btyacc_demo.tab.c"
+#line 855 "btyacc_demo.tab.c"
case 269:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -857,7 +860,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 861 "btyacc_demo.tab.c"
+#line 864 "btyacc_demo.tab.c"
case 59:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -866,7 +869,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 870 "btyacc_demo.tab.c"
+#line 873 "btyacc_demo.tab.c"
case 44:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -875,7 +878,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 879 "btyacc_demo.tab.c"
+#line 882 "btyacc_demo.tab.c"
case 41:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -884,7 +887,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 888 "btyacc_demo.tab.c"
+#line 891 "btyacc_demo.tab.c"
case 93:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -893,7 +896,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 897 "btyacc_demo.tab.c"
+#line 900 "btyacc_demo.tab.c"
case 123:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -902,7 +905,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 906 "btyacc_demo.tab.c"
+#line 909 "btyacc_demo.tab.c"
case 125:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -911,7 +914,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 915 "btyacc_demo.tab.c"
+#line 918 "btyacc_demo.tab.c"
case 270:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -920,7 +923,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 924 "btyacc_demo.tab.c"
+#line 927 "btyacc_demo.tab.c"
case 271:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -929,7 +932,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 933 "btyacc_demo.tab.c"
+#line 936 "btyacc_demo.tab.c"
case 272:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -938,7 +941,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).expr); }
break;
-#line 942 "btyacc_demo.tab.c"
+#line 945 "btyacc_demo.tab.c"
case 273:
#line 67 "btyacc_demo.y"
{ /* 'msg' is a 'char *' indicating the context of destructor invocation*/
@@ -948,7 +951,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).decl->scope); free((*val).decl->type); }
break;
-#line 952 "btyacc_demo.tab.c"
+#line 955 "btyacc_demo.tab.c"
case 274:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -957,7 +960,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 961 "btyacc_demo.tab.c"
+#line 964 "btyacc_demo.tab.c"
case 275:
#line 83 "btyacc_demo.y"
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
@@ -966,7 +969,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
/* in this example, we don't know what to do here */ }
break;
-#line 970 "btyacc_demo.tab.c"
+#line 973 "btyacc_demo.tab.c"
case 276:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -975,7 +978,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).code); }
break;
-#line 979 "btyacc_demo.tab.c"
+#line 982 "btyacc_demo.tab.c"
case 277:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -984,7 +987,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).code); }
break;
-#line 988 "btyacc_demo.tab.c"
+#line 991 "btyacc_demo.tab.c"
case 278:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -993,7 +996,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).code); }
break;
-#line 997 "btyacc_demo.tab.c"
+#line 1000 "btyacc_demo.tab.c"
case 279:
#line 73 "btyacc_demo.y"
{ printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
@@ -1002,7 +1005,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).decl); }
break;
-#line 1006 "btyacc_demo.tab.c"
+#line 1009 "btyacc_demo.tab.c"
case 280:
#line 73 "btyacc_demo.y"
{ printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
@@ -1011,7 +1014,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).decl); }
break;
-#line 1015 "btyacc_demo.tab.c"
+#line 1018 "btyacc_demo.tab.c"
case 281:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1020,7 +1023,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).type); }
break;
-#line 1024 "btyacc_demo.tab.c"
+#line 1027 "btyacc_demo.tab.c"
case 282:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1029,7 +1032,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).type); }
break;
-#line 1033 "btyacc_demo.tab.c"
+#line 1036 "btyacc_demo.tab.c"
case 283:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1038,7 +1041,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).type); }
break;
-#line 1042 "btyacc_demo.tab.c"
+#line 1045 "btyacc_demo.tab.c"
case 284:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1047,7 +1050,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).type); }
break;
-#line 1051 "btyacc_demo.tab.c"
+#line 1054 "btyacc_demo.tab.c"
case 285:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1056,7 +1059,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).type); }
break;
-#line 1060 "btyacc_demo.tab.c"
+#line 1063 "btyacc_demo.tab.c"
case 286:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1065,7 +1068,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1069 "btyacc_demo.tab.c"
+#line 1072 "btyacc_demo.tab.c"
case 287:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1074,7 +1077,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).dlist); }
break;
-#line 1078 "btyacc_demo.tab.c"
+#line 1081 "btyacc_demo.tab.c"
case 288:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1083,7 +1086,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).dlist); }
break;
-#line 1087 "btyacc_demo.tab.c"
+#line 1090 "btyacc_demo.tab.c"
case 289:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1092,7 +1095,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1096 "btyacc_demo.tab.c"
+#line 1099 "btyacc_demo.tab.c"
case 290:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1101,7 +1104,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1105 "btyacc_demo.tab.c"
+#line 1108 "btyacc_demo.tab.c"
case 291:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1110,7 +1113,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1114 "btyacc_demo.tab.c"
+#line 1117 "btyacc_demo.tab.c"
case 292:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1119,7 +1122,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1123 "btyacc_demo.tab.c"
+#line 1126 "btyacc_demo.tab.c"
case 293:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1128,7 +1131,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).type); }
break;
-#line 1132 "btyacc_demo.tab.c"
+#line 1135 "btyacc_demo.tab.c"
case 294:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1137,7 +1140,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1141 "btyacc_demo.tab.c"
+#line 1144 "btyacc_demo.tab.c"
case 295:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1146,7 +1149,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).type); }
break;
-#line 1150 "btyacc_demo.tab.c"
+#line 1153 "btyacc_demo.tab.c"
case 296:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1155,7 +1158,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1159 "btyacc_demo.tab.c"
+#line 1162 "btyacc_demo.tab.c"
case 297:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1164,7 +1167,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1168 "btyacc_demo.tab.c"
+#line 1171 "btyacc_demo.tab.c"
case 298:
#line 78 "btyacc_demo.y"
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
@@ -1173,7 +1176,7 @@ YYDESTRUCT_DECL()
(*loc).last_line, (*loc).last_column);
free((*val).scope); }
break;
-#line 1177 "btyacc_demo.tab.c"
+#line 1180 "btyacc_demo.tab.c"
}
}
#define YYDESTRUCT_IS_DECLARED 1
@@ -1316,7 +1319,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -1383,10 +1386,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -1497,7 +1500,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1707,7 +1710,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1736,7 +1739,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1752,7 +1755,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1838,10 +1841,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -2106,7 +2109,7 @@ case 59:
#line 197 "btyacc_demo.y"
{ yyval.code = yystack.l_mark[-1].code; }
break;
-#line 2110 "btyacc_demo.tab.c"
+#line 2113 "btyacc_demo.tab.c"
default:
break;
}
@@ -2161,12 +2164,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/btyacc_demo.tab.h b/test/btyacc/btyacc_demo.tab.h
index c219fb1fae972..5c2b96cf33101 100644
--- a/test/btyacc/btyacc_demo.tab.h
+++ b/test/btyacc/btyacc_demo.tab.h
@@ -46,5 +46,6 @@ typedef struct YYLTYPE
#define YYLTYPE_IS_DECLARED 1
#endif
#define YYRHSLOC(rhs, k) ((rhs)[k])
+extern YYLTYPE demo_lloc;
#endif /* _demo__defines_h_ */
diff --git a/test/btyacc/btyacc_demo2.error b/test/btyacc/btyacc_demo2.error
deleted file mode 100644
index 554dd5acb0aaf..0000000000000
--- a/test/btyacc/btyacc_demo2.error
+++ /dev/null
@@ -1 +0,0 @@
-YACC: e - line 82 of "./btyacc_demo2.y", $$ is untyped
diff --git a/test/btyacc/btyacc_demo2.tab.c b/test/btyacc/btyacc_demo2.tab.c
deleted file mode 100644
index 6c35f23329b5b..0000000000000
--- a/test/btyacc/btyacc_demo2.tab.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/* original parser id follows */
-/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
-/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
-
-#define YYBYACC 1
-#define YYMAJOR 1
-#define YYMINOR 9
-#define YYCHECK "yyyymmdd"
-
-#define YYEMPTY (-1)
-#define yyclearin (yychar = YYEMPTY)
-#define yyerrok (yyerrflag = 0)
-#define YYRECOVERING() (yyerrflag != 0)
-#define YYENOMEM (-2)
-#define YYEOF 0
diff --git a/test/btyacc/btyacc_destroy1.tab.c b/test/btyacc/btyacc_destroy1.tab.c
index 74c32b10326c2..d445b88b51d09 100644
--- a/test/btyacc/btyacc_destroy1.tab.c
+++ b/test/btyacc/btyacc_destroy1.tab.c
@@ -357,13 +357,16 @@ static const char *const destroy1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -376,17 +379,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -485,7 +488,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 489 "btyacc_destroy1.tab.c"
+#line 492 "btyacc_destroy1.tab.c"
/* Release memory associated with symbol. */
#if ! defined YYDESTRUCT_IS_DECLARED
@@ -505,7 +508,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 509 "btyacc_destroy1.tab.c"
+#line 512 "btyacc_destroy1.tab.c"
}
}
#define YYDESTRUCT_IS_DECLARED 1
@@ -648,7 +651,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -715,10 +718,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -829,7 +832,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1039,7 +1042,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1068,7 +1071,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1084,7 +1087,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1170,10 +1173,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1228,7 +1231,7 @@ case 9:
#line 86 "btyacc_destroy1.y"
{ yyval.nlist = yystack.l_mark[-5].nlist; }
break;
-#line 1232 "btyacc_destroy1.tab.c"
+#line 1235 "btyacc_destroy1.tab.c"
default:
break;
}
@@ -1283,12 +1286,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/btyacc_destroy2.tab.c b/test/btyacc/btyacc_destroy2.tab.c
index 55705eecebc39..59a08e9a973cc 100644
--- a/test/btyacc/btyacc_destroy2.tab.c
+++ b/test/btyacc/btyacc_destroy2.tab.c
@@ -357,13 +357,16 @@ static const char *const destroy2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -376,17 +379,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -485,7 +488,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 489 "btyacc_destroy2.tab.c"
+#line 492 "btyacc_destroy2.tab.c"
/* Release memory associated with symbol. */
#if ! defined YYDESTRUCT_IS_DECLARED
@@ -505,7 +508,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 509 "btyacc_destroy2.tab.c"
+#line 512 "btyacc_destroy2.tab.c"
}
}
#define YYDESTRUCT_IS_DECLARED 1
@@ -648,7 +651,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -715,10 +718,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -829,7 +832,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1039,7 +1042,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1068,7 +1071,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1084,7 +1087,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1170,10 +1173,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1228,7 +1231,7 @@ case 9:
#line 86 "btyacc_destroy2.y"
{ yyval.nlist = yystack.l_mark[-5].nlist; }
break;
-#line 1232 "btyacc_destroy2.tab.c"
+#line 1235 "btyacc_destroy2.tab.c"
default:
break;
}
@@ -1283,12 +1286,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/btyacc_destroy3.tab.c b/test/btyacc/btyacc_destroy3.tab.c
index c6b08b8be2328..136f2f691a9bd 100644
--- a/test/btyacc/btyacc_destroy3.tab.c
+++ b/test/btyacc/btyacc_destroy3.tab.c
@@ -357,13 +357,16 @@ static const char *const destroy3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -376,17 +379,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -485,7 +488,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 489 "btyacc_destroy3.tab.c"
+#line 492 "btyacc_destroy3.tab.c"
/* Release memory associated with symbol. */
#if ! defined YYDESTRUCT_IS_DECLARED
@@ -505,7 +508,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 509 "btyacc_destroy3.tab.c"
+#line 512 "btyacc_destroy3.tab.c"
}
}
#define YYDESTRUCT_IS_DECLARED 1
@@ -648,7 +651,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -715,10 +718,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -829,7 +832,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1039,7 +1042,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1068,7 +1071,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1084,7 +1087,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1170,10 +1173,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1228,7 +1231,7 @@ case 9:
#line 89 "btyacc_destroy3.y"
{ yyval.nlist = yystack.l_mark[-5].nlist; }
break;
-#line 1232 "btyacc_destroy3.tab.c"
+#line 1235 "btyacc_destroy3.tab.c"
default:
break;
}
@@ -1283,12 +1286,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/calc.tab.c b/test/btyacc/calc.tab.c
index 052c7ade4f175..eed4721a63ad3 100644
--- a/test/btyacc/calc.tab.c
+++ b/test/btyacc/calc.tab.c
@@ -338,13 +338,16 @@ static const char *const calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -357,17 +360,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -504,7 +507,7 @@ yylex(void)
}
return( c );
}
-#line 508 "calc.tab.c"
+#line 511 "calc.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -643,7 +646,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -710,10 +713,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -824,7 +827,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1034,7 +1037,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1063,7 +1066,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1079,7 +1082,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1165,10 +1168,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1234,7 +1237,7 @@ case 18:
#line 63 "calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1238 "calc.tab.c"
+#line 1241 "calc.tab.c"
default:
break;
}
@@ -1289,12 +1292,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/calc1.tab.c b/test/btyacc/calc1.tab.c
index 27731448cb885..b919f8c2d3f0b 100644
--- a/test/btyacc/calc1.tab.c
+++ b/test/btyacc/calc1.tab.c
@@ -393,13 +393,16 @@ static const char *const calc1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -412,17 +415,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -648,7 +651,7 @@ vdiv(double a, double b, INTERVAL v)
{
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
}
-#line 652 "calc1.tab.c"
+#line 655 "calc1.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -787,7 +790,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -854,10 +857,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -968,7 +971,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1178,7 +1181,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1207,7 +1210,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1223,7 +1226,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1309,10 +1312,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1481,7 +1484,7 @@ case 28:
yyval.vval = yystack.l_mark[-1].vval;
}
break;
-#line 1485 "calc1.tab.c"
+#line 1488 "calc1.tab.c"
default:
break;
}
@@ -1536,12 +1539,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/calc2.tab.c b/test/btyacc/calc2.tab.c
index 4b4550d577db3..3d83628d2fa9b 100644
--- a/test/btyacc/calc2.tab.c
+++ b/test/btyacc/calc2.tab.c
@@ -340,13 +340,16 @@ static const char *const calc2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -359,17 +362,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -517,7 +520,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 521 "calc2.tab.c"
+#line 524 "calc2.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -656,7 +659,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -723,10 +726,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -837,7 +840,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1047,7 +1050,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1076,7 +1079,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1092,7 +1095,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1178,10 +1181,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1247,7 +1250,7 @@ case 18:
#line 70 "calc2.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1251 "calc2.tab.c"
+#line 1254 "calc2.tab.c"
default:
break;
}
@@ -1302,12 +1305,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/calc3.tab.c b/test/btyacc/calc3.tab.c
index 199c245361a29..ad4aa5b215466 100644
--- a/test/btyacc/calc3.tab.c
+++ b/test/btyacc/calc3.tab.c
@@ -345,8 +345,9 @@ static const char *const calc3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
#ifndef YYLLOC_DEFAULT
@@ -355,17 +356,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -472,7 +473,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 476 "calc3.tab.c"
+#line 477 "calc3.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -609,6 +610,8 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -661,7 +664,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -737,10 +740,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -851,7 +854,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1061,7 +1064,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1090,7 +1093,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1106,7 +1109,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1192,10 +1195,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1261,7 +1264,7 @@ case 18:
#line 73 "calc3.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1265 "calc3.tab.c"
+#line 1268 "calc3.tab.c"
default:
break;
}
@@ -1316,12 +1319,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/btyacc_demo2.output b/test/btyacc/calc_code_all.error
index e69de29bb2d1d..e69de29bb2d1d 100644
--- a/test/btyacc/btyacc_demo2.output
+++ b/test/btyacc/calc_code_all.error
diff --git a/test/btyacc/calc_code_all.output b/test/btyacc/calc_code_all.output
new file mode 100644
index 0000000000000..c689eec0535a1
--- /dev/null
+++ b/test/btyacc/calc_code_all.output
@@ -0,0 +1,485 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
+
+grammar parser grammar
+symbol# value# symbol
+ 0 0 $end
+ 1 256 error
+ 2 257 DIGIT
+ 3 258 LETTER
+ 4 124 '|'
+ 5 38 '&'
+ 6 43 '+'
+ 7 45 '-'
+ 8 42 '*'
+ 9 47 '/'
+ 10 37 '%'
+ 11 259 UMINUS
+ 12 10 '\n'
+ 13 61 '='
+ 14 40 '('
+ 15 41 ')'
+ 16 260 $accept
+ 17 261 list
+ 18 262 stat
+ 19 263 expr
+ 20 264 number
diff --git a/test/btyacc/calc_code_all.tab.c b/test/btyacc/calc_code_all.tab.c
new file mode 100644
index 0000000000000..5f8b705e21e56
--- /dev/null
+++ b/test/btyacc/calc_code_all.tab.c
@@ -0,0 +1,1502 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+/* %code "top" block start */
+#line 5 "calc_code_all.y"
+/* CODE-TOP */
+/* %code "top" block end */
+#line 22 "calc_code_all.tab.c"
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+
+#ifndef yyparse
+#define yyparse calc_code_all_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_all_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_all_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_all_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_all_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_all_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_all_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_all_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_all_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_all_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_all_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_all_defred
+#endif /* yydefred */
+
+#ifndef yystos
+#define yystos calc_code_all_stos
+#endif /* yystos */
+
+#ifndef yydgoto
+#define yydgoto calc_code_all_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_all_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_all_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_all_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_all_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_all_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_all_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_all_rule
+#endif /* yyrule */
+
+#if YYBTYACC
+
+#ifndef yycindex
+#define yycindex calc_code_all_cindex
+#endif /* yycindex */
+
+#ifndef yyctable
+#define yyctable calc_code_all_ctable
+#endif /* yyctable */
+
+#endif /* YYBTYACC */
+
+#define YYPREFIX "calc_code_all_"
+
+#define YYPURE 0
+
+#line 9 "calc_code_all.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 137 "calc_code_all.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_all_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_all_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_all_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT calc_code_all_stos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT calc_code_all_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_all_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_all_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT calc_code_all_cindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT calc_code_all_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_all_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_all_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT calc_code_all_ctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_all_name[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const calc_code_all_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+/* %code "requires" block start */
+#line 3 "calc_code_all.y"
+/* CODE-REQUIRES */
+/* %code "requires" block end */
+#line 367 "calc_code_all.tab.c"
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+
+/* %code "provides" block start */
+#line 4 "calc_code_all.y"
+/* CODE-PROVIDES */
+#line 6 "calc_code_all.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
+#line 488 "calc_code_all.tab.c"
+
+/* %code "" block start */
+#line 1 "calc_code_all.y"
+/* CODE-DEFAULT2 */
+#line 2 "calc_code_all.y"
+/* CODE-DEFAULT */
+/* %code "" block end */
+#line 496 "calc_code_all.tab.c"
+#line 73 "calc_code_all.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 539 "calc_code_all.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 35 "calc_code_all.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "calc_code_all.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "calc_code_all.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "calc_code_all.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "calc_code_all.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "calc_code_all.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "calc_code_all.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "calc_code_all.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1269 "calc_code_all.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/calc_code_all.tab.h b/test/btyacc/calc_code_all.tab.h
new file mode 100644
index 0000000000000..e79ea7ab93004
--- /dev/null
+++ b/test/btyacc/calc_code_all.tab.h
@@ -0,0 +1,18 @@
+#ifndef _calc_code_all__defines_h_
+#define _calc_code_all__defines_h_
+
+/* %code "requires" block start */
+#line 3 "calc_code_all.y"
+/* CODE-REQUIRES */
+/* %code "requires" block end */
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+/* %code "provides" block start */
+#line 4 "calc_code_all.y"
+/* CODE-PROVIDES */
+#line 6 "calc_code_all.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
+
+#endif /* _calc_code_all__defines_h_ */
diff --git a/test/btyacc/btyacc_demo2.tab.h b/test/btyacc/calc_code_default.error
index e69de29bb2d1d..e69de29bb2d1d 100644
--- a/test/btyacc/btyacc_demo2.tab.h
+++ b/test/btyacc/calc_code_default.error
diff --git a/test/btyacc/calc_code_default.output b/test/btyacc/calc_code_default.output
new file mode 100644
index 0000000000000..c689eec0535a1
--- /dev/null
+++ b/test/btyacc/calc_code_default.output
@@ -0,0 +1,485 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
+
+grammar parser grammar
+symbol# value# symbol
+ 0 0 $end
+ 1 256 error
+ 2 257 DIGIT
+ 3 258 LETTER
+ 4 124 '|'
+ 5 38 '&'
+ 6 43 '+'
+ 7 45 '-'
+ 8 42 '*'
+ 9 47 '/'
+ 10 37 '%'
+ 11 259 UMINUS
+ 12 10 '\n'
+ 13 61 '='
+ 14 40 '('
+ 15 41 ')'
+ 16 260 $accept
+ 17 261 list
+ 18 262 stat
+ 19 263 expr
+ 20 264 number
diff --git a/test/btyacc/calc_code_default.tab.c b/test/btyacc/calc_code_default.tab.c
new file mode 100644
index 0000000000000..2bd97913bbf54
--- /dev/null
+++ b/test/btyacc/calc_code_default.tab.c
@@ -0,0 +1,1482 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+
+#ifndef yyparse
+#define yyparse calc_code_default_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_default_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_default_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_default_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_default_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_default_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_default_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_default_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_default_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_default_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_default_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_default_defred
+#endif /* yydefred */
+
+#ifndef yystos
+#define yystos calc_code_default_stos
+#endif /* yystos */
+
+#ifndef yydgoto
+#define yydgoto calc_code_default_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_default_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_default_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_default_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_default_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_default_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_default_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_default_rule
+#endif /* yyrule */
+
+#if YYBTYACC
+
+#ifndef yycindex
+#define yycindex calc_code_default_cindex
+#endif /* yycindex */
+
+#ifndef yyctable
+#define yyctable calc_code_default_ctable
+#endif /* yyctable */
+
+#endif /* YYBTYACC */
+
+#define YYPREFIX "calc_code_default_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_default.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 131 "calc_code_default.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_default_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_default_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_default_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT calc_code_default_stos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT calc_code_default_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_default_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_default_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT calc_code_default_cindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT calc_code_default_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_default_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_default_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT calc_code_default_ctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_default_name[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const calc_code_default_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+
+/* %code "" block start */
+#line 1 "calc_code_default.y"
+/* CODE-DEFAULT */
+#line 2 "calc_code_default.y"
+/* CODE-DEFAULT2 */
+/* %code "" block end */
+#line 476 "calc_code_default.tab.c"
+#line 69 "calc_code_default.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 519 "calc_code_default.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_default.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_default.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_default.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_default.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_default.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_default.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_default.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_default.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1249 "calc_code_default.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/calc_code_default.tab.h b/test/btyacc/calc_code_default.tab.h
new file mode 100644
index 0000000000000..6f673cc8bc163
--- /dev/null
+++ b/test/btyacc/calc_code_default.tab.h
@@ -0,0 +1,8 @@
+#ifndef _calc_code_default__defines_h_
+#define _calc_code_default__defines_h_
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+
+#endif /* _calc_code_default__defines_h_ */
diff --git a/test/btyacc/code_debug.error b/test/btyacc/calc_code_imports.error
index e69de29bb2d1d..e69de29bb2d1d 100644
--- a/test/btyacc/code_debug.error
+++ b/test/btyacc/calc_code_imports.error
diff --git a/test/btyacc/calc_code_imports.output b/test/btyacc/calc_code_imports.output
new file mode 100644
index 0000000000000..c689eec0535a1
--- /dev/null
+++ b/test/btyacc/calc_code_imports.output
@@ -0,0 +1,485 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
+
+grammar parser grammar
+symbol# value# symbol
+ 0 0 $end
+ 1 256 error
+ 2 257 DIGIT
+ 3 258 LETTER
+ 4 124 '|'
+ 5 38 '&'
+ 6 43 '+'
+ 7 45 '-'
+ 8 42 '*'
+ 9 47 '/'
+ 10 37 '%'
+ 11 259 UMINUS
+ 12 10 '\n'
+ 13 61 '='
+ 14 40 '('
+ 15 41 ')'
+ 16 260 $accept
+ 17 261 list
+ 18 262 stat
+ 19 263 expr
+ 20 264 number
diff --git a/test/btyacc/calc_code_imports.tab.c b/test/btyacc/calc_code_imports.tab.c
new file mode 100644
index 0000000000000..d918317f24ef1
--- /dev/null
+++ b/test/btyacc/calc_code_imports.tab.c
@@ -0,0 +1,1474 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+
+#ifndef yyparse
+#define yyparse calc_code_imports_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_imports_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_imports_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_imports_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_imports_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_imports_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_imports_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_imports_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_imports_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_imports_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_imports_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_imports_defred
+#endif /* yydefred */
+
+#ifndef yystos
+#define yystos calc_code_imports_stos
+#endif /* yystos */
+
+#ifndef yydgoto
+#define yydgoto calc_code_imports_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_imports_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_imports_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_imports_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_imports_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_imports_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_imports_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_imports_rule
+#endif /* yyrule */
+
+#if YYBTYACC
+
+#ifndef yycindex
+#define yycindex calc_code_imports_cindex
+#endif /* yycindex */
+
+#ifndef yyctable
+#define yyctable calc_code_imports_ctable
+#endif /* yyctable */
+
+#endif /* YYBTYACC */
+
+#define YYPREFIX "calc_code_imports_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_imports.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 131 "calc_code_imports.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_imports_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_imports_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_imports_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT calc_code_imports_stos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT calc_code_imports_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_imports_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_imports_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT calc_code_imports_cindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT calc_code_imports_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_imports_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_imports_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT calc_code_imports_ctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_imports_name[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const calc_code_imports_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+#line 69 "calc_code_imports.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 511 "calc_code_imports.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_imports.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_imports.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_imports.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_imports.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_imports.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_imports.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_imports.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1241 "calc_code_imports.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/calc_code_imports.tab.h b/test/btyacc/calc_code_imports.tab.h
new file mode 100644
index 0000000000000..eb8e7bc733909
--- /dev/null
+++ b/test/btyacc/calc_code_imports.tab.h
@@ -0,0 +1,8 @@
+#ifndef _calc_code_imports__defines_h_
+#define _calc_code_imports__defines_h_
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+
+#endif /* _calc_code_imports__defines_h_ */
diff --git a/test/btyacc/calc_code_provides.error b/test/btyacc/calc_code_provides.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/calc_code_provides.error
diff --git a/test/btyacc/calc_code_provides.output b/test/btyacc/calc_code_provides.output
new file mode 100644
index 0000000000000..c689eec0535a1
--- /dev/null
+++ b/test/btyacc/calc_code_provides.output
@@ -0,0 +1,485 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
+
+grammar parser grammar
+symbol# value# symbol
+ 0 0 $end
+ 1 256 error
+ 2 257 DIGIT
+ 3 258 LETTER
+ 4 124 '|'
+ 5 38 '&'
+ 6 43 '+'
+ 7 45 '-'
+ 8 42 '*'
+ 9 47 '/'
+ 10 37 '%'
+ 11 259 UMINUS
+ 12 10 '\n'
+ 13 61 '='
+ 14 40 '('
+ 15 41 ')'
+ 16 260 $accept
+ 17 261 list
+ 18 262 stat
+ 19 263 expr
+ 20 264 number
diff --git a/test/btyacc/calc_code_provides.tab.c b/test/btyacc/calc_code_provides.tab.c
new file mode 100644
index 0000000000000..e617348e85b29
--- /dev/null
+++ b/test/btyacc/calc_code_provides.tab.c
@@ -0,0 +1,1482 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+
+#ifndef yyparse
+#define yyparse calc_code_provides_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_provides_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_provides_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_provides_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_provides_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_provides_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_provides_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_provides_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_provides_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_provides_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_provides_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_provides_defred
+#endif /* yydefred */
+
+#ifndef yystos
+#define yystos calc_code_provides_stos
+#endif /* yystos */
+
+#ifndef yydgoto
+#define yydgoto calc_code_provides_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_provides_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_provides_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_provides_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_provides_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_provides_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_provides_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_provides_rule
+#endif /* yyrule */
+
+#if YYBTYACC
+
+#ifndef yycindex
+#define yycindex calc_code_provides_cindex
+#endif /* yycindex */
+
+#ifndef yyctable
+#define yyctable calc_code_provides_ctable
+#endif /* yyctable */
+
+#endif /* YYBTYACC */
+
+#define YYPREFIX "calc_code_provides_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_provides.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 131 "calc_code_provides.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_provides_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_provides_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_provides_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT calc_code_provides_stos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT calc_code_provides_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_provides_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_provides_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT calc_code_provides_cindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT calc_code_provides_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_provides_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_provides_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT calc_code_provides_ctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_provides_name[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const calc_code_provides_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+
+/* %code "provides" block start */
+#line 1 "calc_code_provides.y"
+/* CODE-PROVIDES */
+#line 2 "calc_code_provides.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
+#line 476 "calc_code_provides.tab.c"
+#line 69 "calc_code_provides.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 519 "calc_code_provides.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_provides.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_provides.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_provides.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_provides.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_provides.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_provides.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_provides.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1249 "calc_code_provides.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/calc_code_provides.tab.h b/test/btyacc/calc_code_provides.tab.h
new file mode 100644
index 0000000000000..1ca968af458cc
--- /dev/null
+++ b/test/btyacc/calc_code_provides.tab.h
@@ -0,0 +1,14 @@
+#ifndef _calc_code_provides__defines_h_
+#define _calc_code_provides__defines_h_
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+/* %code "provides" block start */
+#line 1 "calc_code_provides.y"
+/* CODE-PROVIDES */
+#line 2 "calc_code_provides.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
+
+#endif /* _calc_code_provides__defines_h_ */
diff --git a/test/btyacc/calc_code_requires.error b/test/btyacc/calc_code_requires.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/calc_code_requires.error
diff --git a/test/btyacc/calc_code_requires.output b/test/btyacc/calc_code_requires.output
new file mode 100644
index 0000000000000..c689eec0535a1
--- /dev/null
+++ b/test/btyacc/calc_code_requires.output
@@ -0,0 +1,485 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
+
+grammar parser grammar
+symbol# value# symbol
+ 0 0 $end
+ 1 256 error
+ 2 257 DIGIT
+ 3 258 LETTER
+ 4 124 '|'
+ 5 38 '&'
+ 6 43 '+'
+ 7 45 '-'
+ 8 42 '*'
+ 9 47 '/'
+ 10 37 '%'
+ 11 259 UMINUS
+ 12 10 '\n'
+ 13 61 '='
+ 14 40 '('
+ 15 41 ')'
+ 16 260 $accept
+ 17 261 list
+ 18 262 stat
+ 19 263 expr
+ 20 264 number
diff --git a/test/btyacc/calc_code_requires.tab.c b/test/btyacc/calc_code_requires.tab.c
new file mode 100644
index 0000000000000..95a093cceabca
--- /dev/null
+++ b/test/btyacc/calc_code_requires.tab.c
@@ -0,0 +1,1482 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+
+#ifndef yyparse
+#define yyparse calc_code_requires_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_requires_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_requires_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_requires_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_requires_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_requires_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_requires_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_requires_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_requires_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_requires_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_requires_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_requires_defred
+#endif /* yydefred */
+
+#ifndef yystos
+#define yystos calc_code_requires_stos
+#endif /* yystos */
+
+#ifndef yydgoto
+#define yydgoto calc_code_requires_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_requires_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_requires_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_requires_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_requires_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_requires_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_requires_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_requires_rule
+#endif /* yyrule */
+
+#if YYBTYACC
+
+#ifndef yycindex
+#define yycindex calc_code_requires_cindex
+#endif /* yycindex */
+
+#ifndef yyctable
+#define yyctable calc_code_requires_ctable
+#endif /* yyctable */
+
+#endif /* YYBTYACC */
+
+#define YYPREFIX "calc_code_requires_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_requires.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 131 "calc_code_requires.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_requires_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_requires_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_requires_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT calc_code_requires_stos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT calc_code_requires_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_requires_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_requires_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT calc_code_requires_cindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT calc_code_requires_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_requires_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_requires_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT calc_code_requires_ctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_requires_name[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const calc_code_requires_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+/* %code "requires" block start */
+#line 1 "calc_code_requires.y"
+/* CODE-REQUIRES */
+#line 2 "calc_code_requires.y"
+/* CODE-REQUIRES2 */
+/* %code "requires" block end */
+#line 363 "calc_code_requires.tab.c"
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+#line 69 "calc_code_requires.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 519 "calc_code_requires.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_requires.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_requires.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_requires.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_requires.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_requires.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_requires.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_requires.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1249 "calc_code_requires.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/calc_code_requires.tab.h b/test/btyacc/calc_code_requires.tab.h
new file mode 100644
index 0000000000000..d5b711b534aa9
--- /dev/null
+++ b/test/btyacc/calc_code_requires.tab.h
@@ -0,0 +1,14 @@
+#ifndef _calc_code_requires__defines_h_
+#define _calc_code_requires__defines_h_
+
+/* %code "requires" block start */
+#line 1 "calc_code_requires.y"
+/* CODE-REQUIRES */
+#line 2 "calc_code_requires.y"
+/* CODE-REQUIRES2 */
+/* %code "requires" block end */
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+
+#endif /* _calc_code_requires__defines_h_ */
diff --git a/test/btyacc/calc_code_top.error b/test/btyacc/calc_code_top.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/calc_code_top.error
diff --git a/test/btyacc/calc_code_top.output b/test/btyacc/calc_code_top.output
new file mode 100644
index 0000000000000..c689eec0535a1
--- /dev/null
+++ b/test/btyacc/calc_code_top.output
@@ -0,0 +1,485 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
+
+grammar parser grammar
+symbol# value# symbol
+ 0 0 $end
+ 1 256 error
+ 2 257 DIGIT
+ 3 258 LETTER
+ 4 124 '|'
+ 5 38 '&'
+ 6 43 '+'
+ 7 45 '-'
+ 8 42 '*'
+ 9 47 '/'
+ 10 37 '%'
+ 11 259 UMINUS
+ 12 10 '\n'
+ 13 61 '='
+ 14 40 '('
+ 15 41 ')'
+ 16 260 $accept
+ 17 261 list
+ 18 262 stat
+ 19 263 expr
+ 20 264 number
diff --git a/test/btyacc/calc_code_top.tab.c b/test/btyacc/calc_code_top.tab.c
new file mode 100644
index 0000000000000..11c16f53dc815
--- /dev/null
+++ b/test/btyacc/calc_code_top.tab.c
@@ -0,0 +1,1482 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+/* %code "top" block start */
+#line 1 "calc_code_top.y"
+/* CODE-TOP */
+#line 2 "calc_code_top.y"
+/* CODE-TOP2 */
+/* %code "top" block end */
+#line 24 "calc_code_top.tab.c"
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+
+#ifndef yyparse
+#define yyparse calc_code_top_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_top_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_top_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_top_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_top_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_top_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_top_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_top_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_top_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_top_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_top_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_top_defred
+#endif /* yydefred */
+
+#ifndef yystos
+#define yystos calc_code_top_stos
+#endif /* yystos */
+
+#ifndef yydgoto
+#define yydgoto calc_code_top_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_top_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_top_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_top_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_top_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_top_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_top_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_top_rule
+#endif /* yyrule */
+
+#if YYBTYACC
+
+#ifndef yycindex
+#define yycindex calc_code_top_cindex
+#endif /* yycindex */
+
+#ifndef yyctable
+#define yyctable calc_code_top_ctable
+#endif /* yyctable */
+
+#endif /* YYBTYACC */
+
+#define YYPREFIX "calc_code_top_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_top.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 139 "calc_code_top.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_top_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_top_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_top_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT calc_code_top_stos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT calc_code_top_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_top_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_top_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT calc_code_top_cindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT calc_code_top_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_top_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_top_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT calc_code_top_ctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_top_name[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const calc_code_top_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+#line 69 "calc_code_top.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 519 "calc_code_top.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_top.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_top.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_top.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_top.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_top.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_top.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_top.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_top.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1249 "calc_code_top.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/calc_code_top.tab.h b/test/btyacc/calc_code_top.tab.h
new file mode 100644
index 0000000000000..8be78b276e363
--- /dev/null
+++ b/test/btyacc/calc_code_top.tab.h
@@ -0,0 +1,8 @@
+#ifndef _calc_code_top__defines_h_
+#define _calc_code_top__defines_h_
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+
+#endif /* _calc_code_top__defines_h_ */
diff --git a/test/btyacc/code_calc.code.c b/test/btyacc/code_calc.code.c
index e2e4c12454728..3e8dc966ddd45 100644
--- a/test/btyacc/code_calc.code.c
+++ b/test/btyacc/code_calc.code.c
@@ -207,13 +207,16 @@ extern const char *const yyname[];
extern const char *const yyrule[];
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -226,17 +229,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -377,7 +380,7 @@ yylex(void)
}
return( c );
}
-#line 381 "code_calc.code.c"
+#line 384 "code_calc.code.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -516,7 +519,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -583,10 +586,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -697,7 +700,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -907,7 +910,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -936,7 +939,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -952,7 +955,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1038,10 +1041,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1107,7 +1110,7 @@ case 18:
#line 67 "code_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1111 "code_calc.code.c"
+#line 1114 "code_calc.code.c"
default:
break;
}
@@ -1162,12 +1165,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/code_debug.i b/test/btyacc/code_debug.i
deleted file mode 100644
index b8f2144e197f3..0000000000000
--- a/test/btyacc/code_debug.i
+++ /dev/null
@@ -1,60 +0,0 @@
-#define YYPREFIX "yy"
-
-#define YYPURE 0
-
-#line 2 "code_debug.y"
-
-#ifdef YYBISON
-int yylex(void);
-static void yyerror(const char *);
-#endif
-
-
-#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
-/* Default: YYSTYPE is the semantic value type. */
-typedef int YYSTYPE;
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-/* compatibility with bison */
-#ifdef YYPARSE_PARAM
-/* compatibility with FreeBSD */
-# ifdef YYPARSE_PARAM_TYPE
-# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
-# else
-# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
-# endif
-#else
-# define YYPARSE_DECL() yyparse(void)
-#endif
-
-/* Parameters sent to lex. */
-#ifdef YYLEX_PARAM
-# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
-# define YYLEX yylex(YYLEX_PARAM)
-#else
-# define YYLEX_DECL() yylex(void)
-# define YYLEX yylex()
-#endif
-
-/* Parameters sent to yyerror. */
-#ifndef YYERROR_DECL
-#define YYERROR_DECL() yyerror(const char *s)
-#endif
-#ifndef YYERROR_CALL
-#define YYERROR_CALL(msg) yyerror(msg)
-#endif
-
-extern int YYPARSE_DECL();
-
-extern int yydebug;
-extern int yynerrs;
-
-extern int yyerrflag;
-extern int yychar;
-extern YYSTYPE yyval;
-extern YYSTYPE yylval;
-#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
-extern YYLTYPE yyloc; /* position returned by actions */
-extern YYLTYPE yylloc; /* position from the lexer */
-#endif
diff --git a/test/btyacc/code_debug.output b/test/btyacc/code_debug.output
deleted file mode 100644
index 1e56c214a6cc3..0000000000000
--- a/test/btyacc/code_debug.output
+++ /dev/null
@@ -1,34 +0,0 @@
- 0 $accept : S $end
-
- 1 S : error
-
-state 0
- $accept : . S $end (0)
-
- error shift 1
- . error
-
- S goto 2
-
-
-state 1
- S : error . (1)
-
- . reduce 1
-
-
-state 2
- $accept : S . $end (0)
-
- $end accept
-
-
-2 terminals, 2 nonterminals
-2 grammar rules, 3 states
-
-grammar parser grammar
-symbol# value# symbol
- 0 0 $end
- 1 256 error
- 2 257 $accept
- 3 258 S
diff --git a/test/btyacc/code_error.code.c b/test/btyacc/code_error.code.c
index 6169071c835de..df0dc1a5af068 100644
--- a/test/btyacc/code_error.code.c
+++ b/test/btyacc/code_error.code.c
@@ -197,13 +197,16 @@ extern const char *const yyname[];
extern const char *const yyrule[];
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -216,17 +219,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -347,7 +350,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 351 "code_error.code.c"
+#line 354 "code_error.code.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -486,7 +489,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -553,10 +556,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -667,7 +670,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -877,7 +880,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -906,7 +909,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -922,7 +925,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1008,10 +1011,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1071,12 +1074,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/code_debug.c b/test/btyacc/defines1.calc.c
index bf002572304b2..ff8fcc62d0f1d 100644
--- a/test/btyacc/code_debug.c
+++ b/test/btyacc/defines1.calc.c
@@ -16,78 +16,245 @@
#undef YYBTYACC
#define YYBTYACC 0
#define YYDEBUGSTR YYPREFIX "debug"
-#line 20 "code_debug.c"
-#include "rename_debug.i"
-#include "rename_debug.h"
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 34 "y.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
typedef short YYINT;
static const YYINT yylhs[] = { -1,
- 0,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
};
static const YYINT yylen[] = { 2,
- 1,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
};
-static const YYINT yydefred[] = { 0,
- 1, 0,
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
static const YYINT yystos[] = { 0,
- 256, 258,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
};
-static const YYINT yydgoto[] = { 2,
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
};
-static const YYINT yysindex[] = { -256,
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
0, 0,
};
static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
0, 0,
};
#if YYBTYACC
static const YYINT yycindex[] = { 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, 0, 0, 0, 0,
0, 0,
};
#endif
static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
};
-#define YYTABLESIZE 0
-static const YYINT yytable[] = { 1,
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
};
-static const YYINT yycheck[] = { 256,
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
};
#if YYBTYACC
-static const YYINT yyctable[] = { 0,
+static const YYINT yyctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
};
#endif
-#define YYFINAL 2
+#define YYFINAL 1
#ifndef YYDEBUG
-#define YYDEBUG 1
+#define YYDEBUG 0
#endif
-#define YYMAXTOKEN 256
-#define YYUNDFTOKEN 259
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
#if YYDEBUG
static const char *const yyname[] = {
-"$end",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,0,0,0,0,0,0,0,0,0,
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,"error","$accept","S","illegal-symbol",
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
};
static const char *const yyrule[] = {
-"$accept : S",
-"S : error",
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -100,17 +267,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -141,9 +308,9 @@ do \
typedef struct {
unsigned stacksize;
- short *s_base;
- short *s_mark;
- short *s_last;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
@@ -201,37 +368,53 @@ static YYLTYPE *yylplim = 0;
#endif
/* Current position at lexical token queue */
-static short *yylexp = 0;
+static YYINT *yylexp = 0;
-static short *yylexemes = 0;
+static YYINT *yylexemes = 0;
#endif /* YYBTYACC */
-#line 12 "code_debug.y"
-
-#include <stdio.h>
-
-#ifdef YYBYACC
-extern int YYLEX_DECL();
-#endif
+#line 66 "calc.y"
+ /* start of programs */
int
-main(void)
+main (void)
{
- printf("yyparse() = %d\n", yyparse());
+ while(!feof(stdin)) {
+ yyparse();
+ }
return 0;
}
-int
-yylex(void)
+static void
+yyerror(const char *s)
{
- return -1;
+ fprintf(stderr, "%s\n", s);
}
-static void
-yyerror(const char* s)
+int
+yylex(void)
{
- printf("%s\n", s);
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
}
-#line 236 "code_debug.c"
+#line 418 "y.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -240,7 +423,7 @@ yyerror(const char* s)
#endif /* YYBTYACC */
#if YYDEBUG
-#include <stdio.h> /* needed for printf */
+#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
@@ -251,7 +434,7 @@ static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
- short *newss;
+ YYINT *newss;
YYSTYPE *newvs;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE *newps;
@@ -265,7 +448,7 @@ static int yygrowstack(YYSTACKDATA *data)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
- newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return YYENOMEM;
@@ -329,7 +512,7 @@ yyNewState(unsigned size)
#endif
return p;
}
- p->yystack.s_base = (short *) malloc(size * sizeof(short));
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
if (p->yystack.s_base == NULL) return NULL;
p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
if (p->yystack.l_base == NULL) return NULL;
@@ -370,7 +553,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -384,11 +567,16 @@ YYPARSE_DECL()
if (yydebug)
fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
#if YYBTYACC
yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
yyps->save = 0;
#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
@@ -428,14 +616,14 @@ yyloop:
/* in trial mode; save scanner results for future parse attempts */
if (yylvp == yylvlim)
{ /* Enlarge lexical value queue */
- int p = yylvp - yylvals;
- int s = yylvlim - yylvals;
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
- if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -445,7 +633,7 @@ yyloop:
#endif
yylexp = yylexemes + p;
}
- *yylexp = (short) YYLEX;
+ *yylexp = (YYINT) YYLEX;
*yylvp++ = yylval;
yylve++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
@@ -462,11 +650,10 @@ yyloop:
} while (0);
#endif /* YYBTYACC */
if (yychar < 0) yychar = YYEOF;
- /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
#if YYDEBUG
if (yydebug)
{
- yys = yyname[YYTRANSLATE(yychar)];
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
YYDEBUGSTR, yydepth, yystate, yychar, yys);
#ifdef YYSTYPE_TOSTRING
@@ -525,12 +712,12 @@ yyloop:
save->state = yystate;
save->errflag = yyerrflag;
save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
- memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
- memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
- memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
ctry = yytable[yyn];
if (yyctable[ctry] == -1)
@@ -547,7 +734,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -571,7 +758,7 @@ yyloop:
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
*yylpe++ = yylloc;
#endif
- *yylexp = (short) yychar;
+ *yylexp = (YYINT) yychar;
yychar = YYEMPTY;
}
}
@@ -585,7 +772,7 @@ yyloop:
yylexp--;
yychar = YYEMPTY;
}
- save->lexeme = yylvp - yylvals;
+ save->lexeme = (int) (yylvp - yylvals);
yyps->save = save;
}
if (yytable[yyn] == ctry)
@@ -606,7 +793,7 @@ yyloop:
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
goto yyoverflow;
yystate = yyctable[ctry];
- *++yystack.s_mark = (short) yystate;
+ *++yystack.s_mark = (YYINT) yystate;
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
*++yystack.p_mark = yylloc;
@@ -652,9 +839,18 @@ yyloop:
yynewerrflag = 1;
goto yyerrhandler;
- goto yyerrlab;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
yynewerrflag = 0;
yyerrhandler:
while (yyps->save)
@@ -679,14 +875,14 @@ yyerrhandler:
yyerrctx->state = yystate;
yyerrctx->errflag = yyerrflag;
yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
- memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
- memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
- memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
- yyerrctx->lexeme = yylvp - yylvals;
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
}
yylvp = yylvals + save->lexeme;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
@@ -695,12 +891,12 @@ yyerrhandler:
yylexp = yylexemes + save->lexeme;
yychar = YYEMPTY;
yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
- memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
- memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
- memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
ctry = ++save->ctry;
yystate = save->state;
@@ -730,12 +926,12 @@ yyerrhandler:
yylloc = yylpp[-1];
#endif
yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
- memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
- memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
- memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
yystate = yyerrctx->state;
yyFreeState(yyerrctx);
@@ -748,11 +944,11 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
- goto yyerrlab;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
yyerrlab:
#endif
++yynerrs;
@@ -777,7 +973,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -793,7 +989,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -821,7 +1017,7 @@ yyinrecovery:
#if YYDEBUG
if (yydebug)
{
- yys = yyname[YYTRANSLATE(yychar)];
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
YYDEBUGSTR, yydepth, yystate, yychar, yys);
}
@@ -879,15 +1075,76 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
switch (yyn)
{
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1148 "y.tab.c"
default:
break;
}
@@ -938,16 +1195,16 @@ yyreduce:
/* in trial mode; save scanner results for future parse attempts */
if (yylvp == yylvlim)
{ /* Enlarge lexical value queue */
- int p = yylvp - yylvals;
- int s = yylvlim - yylvals;
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
@@ -958,7 +1215,7 @@ yyreduce:
#endif
yylexp = yylexemes + p;
}
- *yylexp = (short) YYLEX;
+ *yylexp = (YYINT) YYLEX;
*yylvp++ = yylval;
yylve++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
@@ -975,12 +1232,11 @@ yyreduce:
} while (0);
#endif /* YYBTYACC */
if (yychar < 0) yychar = YYEOF;
- /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
#if YYDEBUG
if (yydebug)
{
- yys = yyname[YYTRANSLATE(yychar)];
- fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
}
#endif
@@ -1007,7 +1263,7 @@ yyreduce:
}
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
- *++yystack.s_mark = (short) yystate;
+ *++yystack.s_mark = (YYINT) yystate;
*++yystack.l_mark = yyval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
*++yystack.p_mark = yyloc;
@@ -1042,12 +1298,12 @@ yyvalid:
yylexp = yylexemes + yypath->lexeme;
yychar = YYEMPTY;
yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
- memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
- memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
- memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
yystate = yypath->state;
goto yyloop;
diff --git a/test/btyacc/code_debug.h b/test/btyacc/defines1.calc.h
index ba44e7d75a77a..64c392589c061 100644
--- a/test/btyacc/code_debug.h
+++ b/test/btyacc/defines1.calc.h
@@ -1,6 +1,8 @@
#ifndef _yy_defines_h_
#define _yy_defines_h_
-#define YYERRCODE 256
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
#endif /* _yy_defines_h_ */
diff --git a/test/btyacc/defines1.error b/test/btyacc/defines1.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/defines1.error
diff --git a/test/btyacc/defines1.output b/test/btyacc/defines1.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/defines1.output
diff --git a/test/btyacc/defines2.calc.c b/test/btyacc/defines2.calc.c
new file mode 100644
index 0000000000000..ff8fcc62d0f1d
--- /dev/null
+++ b/test/btyacc/defines2.calc.c
@@ -0,0 +1,1381 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 34 "y.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT yystos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT yycindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT yyctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 418 "y.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1148 "y.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/defines2.calc.h b/test/btyacc/defines2.calc.h
new file mode 100644
index 0000000000000..64c392589c061
--- /dev/null
+++ b/test/btyacc/defines2.calc.h
@@ -0,0 +1,8 @@
+#ifndef _yy_defines_h_
+#define _yy_defines_h_
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+
+#endif /* _yy_defines_h_ */
diff --git a/test/btyacc/defines2.error b/test/btyacc/defines2.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/defines2.error
diff --git a/test/btyacc/defines2.output b/test/btyacc/defines2.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/defines2.output
diff --git a/test/btyacc/defines3.calc.c b/test/btyacc/defines3.calc.c
new file mode 100644
index 0000000000000..cfcd0f87c81e2
--- /dev/null
+++ b/test/btyacc/defines3.calc.c
@@ -0,0 +1,1381 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 34 "prefix.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT yystos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT yycindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT yyctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 418 "prefix.tab.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1148 "prefix.tab.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/defines3.calc.h b/test/btyacc/defines3.calc.h
new file mode 100644
index 0000000000000..64c392589c061
--- /dev/null
+++ b/test/btyacc/defines3.calc.h
@@ -0,0 +1,8 @@
+#ifndef _yy_defines_h_
+#define _yy_defines_h_
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+
+#endif /* _yy_defines_h_ */
diff --git a/test/btyacc/defines3.error b/test/btyacc/defines3.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/defines3.error
diff --git a/test/btyacc/defines3.output b/test/btyacc/defines3.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/defines3.output
diff --git a/test/btyacc/empty.tab.c b/test/btyacc/empty.tab.c
index 11c252d1b1c36..0603419421bac 100644
--- a/test/btyacc/empty.tab.c
+++ b/test/btyacc/empty.tab.c
@@ -229,13 +229,16 @@ static const char *const empty_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -248,17 +251,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -366,7 +369,7 @@ static void
YYERROR_DECL() {
printf("%s\n",s);
}
-#line 370 "empty.tab.c"
+#line 373 "empty.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -505,7 +508,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -572,10 +575,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -686,7 +689,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -896,7 +899,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -925,7 +928,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -941,7 +944,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1027,10 +1030,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1090,12 +1093,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/err_inherit3.tab.c b/test/btyacc/err_inherit3.tab.c
index 9ccaa5bd1baf6..c3527476d023c 100644
--- a/test/btyacc/err_inherit3.tab.c
+++ b/test/btyacc/err_inherit3.tab.c
@@ -290,13 +290,16 @@ static const char *const err_inherit3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -309,17 +312,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -418,7 +421,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 422 "err_inherit3.tab.c"
+#line 425 "err_inherit3.tab.c"
/* Release memory associated with symbol. */
#if ! defined YYDESTRUCT_IS_DECLARED
@@ -438,7 +441,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 442 "err_inherit3.tab.c"
+#line 445 "err_inherit3.tab.c"
case 264:
#line 30 "err_inherit3.y"
{
@@ -450,7 +453,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 454 "err_inherit3.tab.c"
+#line 457 "err_inherit3.tab.c"
case 265:
#line 30 "err_inherit3.y"
{
@@ -462,7 +465,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 466 "err_inherit3.tab.c"
+#line 469 "err_inherit3.tab.c"
}
}
#define YYDESTRUCT_IS_DECLARED 1
@@ -605,7 +608,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -672,10 +675,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -786,7 +789,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -996,7 +999,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1025,7 +1028,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1041,7 +1044,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1127,10 +1130,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1192,7 +1195,7 @@ case 13:
#line 75 "err_inherit3.y"
{ yyval.nlist = yystack.l_mark[0].nlist; }
break;
-#line 1196 "err_inherit3.tab.c"
+#line 1199 "err_inherit3.tab.c"
default:
break;
}
@@ -1247,12 +1250,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/err_inherit4.tab.c b/test/btyacc/err_inherit4.tab.c
index 6c553b86c8c75..0af941998ccdf 100644
--- a/test/btyacc/err_inherit4.tab.c
+++ b/test/btyacc/err_inherit4.tab.c
@@ -309,13 +309,16 @@ static const char *const err_inherit4_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -328,17 +331,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -437,7 +440,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 441 "err_inherit4.tab.c"
+#line 444 "err_inherit4.tab.c"
/* Release memory associated with symbol. */
#if ! defined YYDESTRUCT_IS_DECLARED
@@ -450,17 +453,17 @@ YYDESTRUCT_DECL()
#line 28 "err_inherit4.y"
{ }
break;
-#line 454 "err_inherit4.tab.c"
+#line 457 "err_inherit4.tab.c"
case 264:
#line 28 "err_inherit4.y"
{ }
break;
-#line 459 "err_inherit4.tab.c"
+#line 462 "err_inherit4.tab.c"
case 265:
#line 28 "err_inherit4.y"
{ }
break;
-#line 464 "err_inherit4.tab.c"
+#line 467 "err_inherit4.tab.c"
}
}
#define YYDESTRUCT_IS_DECLARED 1
@@ -603,7 +606,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -670,10 +673,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -784,7 +787,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -994,7 +997,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1023,7 +1026,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1039,7 +1042,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1125,10 +1128,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1182,7 +1185,7 @@ case 11:
#line 77 "err_inherit4.y"
{ yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; }
break;
-#line 1186 "err_inherit4.tab.c"
+#line 1189 "err_inherit4.tab.c"
default:
break;
}
@@ -1237,12 +1240,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/err_inherit4.tab.h b/test/btyacc/err_inherit4.tab.h
index 758d426b54f59..657f87f078fa0 100644
--- a/test/btyacc/err_inherit4.tab.h
+++ b/test/btyacc/err_inherit4.tab.h
@@ -35,5 +35,6 @@ typedef struct YYLTYPE
#define YYLTYPE_IS_DECLARED 1
#endif
#define YYRHSLOC(rhs, k) ((rhs)[k])
+extern YYLTYPE err_inherit4_lloc;
#endif /* _err_inherit4__defines_h_ */
diff --git a/test/btyacc/err_syntax10.tab.c b/test/btyacc/err_syntax10.tab.c
index ef93d6d843154..b386d18a3a7f3 100644
--- a/test/btyacc/err_syntax10.tab.c
+++ b/test/btyacc/err_syntax10.tab.c
@@ -219,13 +219,16 @@ static const char *const err_syntax10_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -238,17 +241,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -365,7 +368,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 369 "err_syntax10.tab.c"
+#line 372 "err_syntax10.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -504,7 +507,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -571,10 +574,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -685,7 +688,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -895,7 +898,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -924,7 +927,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -940,7 +943,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1026,10 +1029,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1089,12 +1092,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/err_syntax11.tab.c b/test/btyacc/err_syntax11.tab.c
index a6a618bbaf059..1c096215df592 100644
--- a/test/btyacc/err_syntax11.tab.c
+++ b/test/btyacc/err_syntax11.tab.c
@@ -225,13 +225,16 @@ static const char *const err_syntax11_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -244,17 +247,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -371,7 +374,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 375 "err_syntax11.tab.c"
+#line 378 "err_syntax11.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -510,7 +513,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -577,10 +580,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -691,7 +694,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -901,7 +904,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -930,7 +933,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -946,7 +949,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1032,10 +1035,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1095,12 +1098,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/err_syntax12.tab.c b/test/btyacc/err_syntax12.tab.c
index 5cef02b2ce987..86fe5aa4d06cc 100644
--- a/test/btyacc/err_syntax12.tab.c
+++ b/test/btyacc/err_syntax12.tab.c
@@ -231,13 +231,16 @@ static const char *const err_syntax12_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -250,17 +253,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -377,7 +380,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 381 "err_syntax12.tab.c"
+#line 384 "err_syntax12.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -516,7 +519,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -583,10 +586,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -697,7 +700,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -907,7 +910,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -936,7 +939,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -952,7 +955,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1038,10 +1041,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1101,12 +1104,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/err_syntax18.tab.c b/test/btyacc/err_syntax18.tab.c
index 8c81319c3a774..0b6fb87e64058 100644
--- a/test/btyacc/err_syntax18.tab.c
+++ b/test/btyacc/err_syntax18.tab.c
@@ -228,13 +228,16 @@ static const char *const err_syntax18_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -247,17 +250,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -374,7 +377,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 378 "err_syntax18.tab.c"
+#line 381 "err_syntax18.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -513,7 +516,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -580,10 +583,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -694,7 +697,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -904,7 +907,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -933,7 +936,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -949,7 +952,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1035,10 +1038,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1048,7 +1051,7 @@ case 1:
#line 9 "err_syntax18.y"
{ yyval = yystack.l_mark[1]; }
break;
-#line 1052 "err_syntax18.tab.c"
+#line 1055 "err_syntax18.tab.c"
default:
break;
}
@@ -1103,12 +1106,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/err_syntax20.tab.c b/test/btyacc/err_syntax20.tab.c
index f9ccc2a9b6038..62f0ee38dd0f7 100644
--- a/test/btyacc/err_syntax20.tab.c
+++ b/test/btyacc/err_syntax20.tab.c
@@ -223,13 +223,16 @@ static const char *const err_syntax20_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -242,17 +245,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -369,7 +372,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 373 "err_syntax20.tab.c"
+#line 376 "err_syntax20.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -508,7 +511,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -575,10 +578,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -689,7 +692,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -899,7 +902,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -928,7 +931,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -944,7 +947,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1030,10 +1033,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1043,7 +1046,7 @@ case 1:
#line 12 "err_syntax20.y"
{ yystack.l_mark[-1].rechk = 3; }
break;
-#line 1047 "err_syntax20.tab.c"
+#line 1050 "err_syntax20.tab.c"
default:
break;
}
@@ -1098,12 +1101,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/error.tab.c b/test/btyacc/error.tab.c
index 051f78eca0e4c..66148f6ac8fac 100644
--- a/test/btyacc/error.tab.c
+++ b/test/btyacc/error.tab.c
@@ -224,13 +224,16 @@ static const char *const error_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -243,17 +246,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -370,7 +373,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 374 "error.tab.c"
+#line 377 "error.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -509,7 +512,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -576,10 +579,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -690,7 +693,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -900,7 +903,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -929,7 +932,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -945,7 +948,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1031,10 +1034,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1094,12 +1097,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/expr.oxout.tab.c b/test/btyacc/expr.oxout.tab.c
index 64857175c39ce..48d81a685e270 100644
--- a/test/btyacc/expr.oxout.tab.c
+++ b/test/btyacc/expr.oxout.tab.c
@@ -345,13 +345,16 @@ static const char *const expr.oxout_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -364,17 +367,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -1790,7 +1793,7 @@ void yyyUnsolvedInstSearchTrav(yyyGNT *pNode)
-#line 1794 "expr.oxout.tab.c"
+#line 1797 "expr.oxout.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -1929,7 +1932,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -1996,10 +1999,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -2110,7 +2113,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -2320,7 +2323,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -2349,7 +2352,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -2365,7 +2368,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -2451,10 +2454,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -2518,7 +2521,7 @@ case 10:
yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);
yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}}
break;
-#line 2522 "expr.oxout.tab.c"
+#line 2525 "expr.oxout.tab.c"
default:
break;
}
@@ -2573,12 +2576,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/grammar.tab.c b/test/btyacc/grammar.tab.c
index d28354db65346..5d51d60333bf3 100644
--- a/test/btyacc/grammar.tab.c
+++ b/test/btyacc/grammar.tab.c
@@ -144,6 +144,7 @@ static void yyerror(const char *s);
/* #include "cproto.h" */
#define MAX_TEXT_SIZE 1024
+#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3)
/* Prototype styles */
#if OPT_LINTLIBRARY
@@ -404,7 +405,7 @@ haveAnsiParam (void)
}
return FALSE;
}
-#line 408 "grammar.tab.c"
+#line 409 "grammar.tab.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@@ -1048,13 +1049,16 @@ static const char *const grammar_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -1067,17 +1071,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -1172,7 +1176,7 @@ static YYINT *yylexp = 0;
static YYINT *yylexemes = 0;
#endif /* YYBTYACC */
-#line 1014 "grammar.y"
+#line 1015 "grammar.y"
/* lex.yy.c */
#define BEGIN yy_start = 1 + 2 *
@@ -1189,7 +1193,7 @@ extern char *yytext;
extern FILE *yyin, *yyout;
static int curly; /* number of curly brace nesting levels */
-static int ly_count; /* number of occurances of %% */
+static int ly_count; /* number of occurrences of %% */
static int inc_depth; /* include nesting level */
static SymbolTable *included_files; /* files already included */
static int yy_start = 0; /* start state number */
@@ -1343,7 +1347,7 @@ free_parser(void)
#endif
}
#endif
-#line 1347 "grammar.tab.c"
+#line 1351 "grammar.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -1482,7 +1486,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -1549,10 +1553,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -1663,7 +1667,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1873,7 +1877,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1902,7 +1906,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1918,7 +1922,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -2004,29 +2008,29 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
switch (yyn)
{
case 10:
-#line 377 "grammar.y"
+#line 378 "grammar.y"
{
yyerrok;
}
break;
case 11:
-#line 381 "grammar.y"
+#line 382 "grammar.y"
{
yyerrok;
}
break;
case 13:
-#line 392 "grammar.y"
+#line 393 "grammar.y"
{
/* Provide an empty action here so bison will not complain about
* incompatible types in the default action it normally would
@@ -2035,13 +2039,13 @@ case 13:
}
break;
case 14:
-#line 399 "grammar.y"
+#line 400 "grammar.y"
{
/* empty */
}
break;
case 15:
-#line 406 "grammar.y"
+#line 407 "grammar.y"
{
#if OPT_LINTLIBRARY
if (types_out && want_typedef()) {
@@ -2054,7 +2058,7 @@ case 15:
}
break;
case 16:
-#line 417 "grammar.y"
+#line 418 "grammar.y"
{
if (func_params != NULL) {
set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
@@ -2070,32 +2074,32 @@ case 16:
}
break;
case 17:
-#line 431 "grammar.y"
+#line 432 "grammar.y"
{
cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
free_decl_spec(&yystack.l_mark[0].decl_spec);
}
break;
case 18:
-#line 436 "grammar.y"
+#line 437 "grammar.y"
{
end_typedef();
}
break;
case 19:
-#line 443 "grammar.y"
+#line 444 "grammar.y"
{
begin_typedef();
}
break;
case 20:
-#line 447 "grammar.y"
+#line 448 "grammar.y"
{
begin_typedef();
}
break;
case 23:
-#line 459 "grammar.y"
+#line 460 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -2109,7 +2113,7 @@ case 23:
}
break;
case 24:
-#line 471 "grammar.y"
+#line 472 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -2120,7 +2124,7 @@ case 24:
}
break;
case 25:
-#line 483 "grammar.y"
+#line 484 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
@@ -2133,7 +2137,7 @@ case 25:
}
break;
case 26:
-#line 494 "grammar.y"
+#line 495 "grammar.y"
{
/* If we're converting to K&R and we've got a nominally K&R
* function which has a parameter which is ANSI (i.e., a prototyped
@@ -2159,7 +2163,7 @@ case 26:
}
break;
case 28:
-#line 519 "grammar.y"
+#line 520 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
yyerror("syntax error");
@@ -2171,7 +2175,7 @@ case 28:
}
break;
case 29:
-#line 529 "grammar.y"
+#line 530 "grammar.y"
{
DeclSpec decl_spec;
@@ -2189,7 +2193,7 @@ case 29:
}
break;
case 36:
-#line 560 "grammar.y"
+#line 561 "grammar.y"
{
join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
free(yystack.l_mark[-1].decl_spec.text);
@@ -2197,115 +2201,115 @@ case 36:
}
break;
case 40:
-#line 575 "grammar.y"
+#line 576 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 41:
-#line 579 "grammar.y"
+#line 580 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
}
break;
case 42:
-#line 583 "grammar.y"
+#line 584 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 43:
-#line 587 "grammar.y"
+#line 588 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
}
break;
case 44:
-#line 591 "grammar.y"
+#line 592 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
}
break;
case 45:
-#line 595 "grammar.y"
+#line 596 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
}
break;
case 46:
-#line 602 "grammar.y"
+#line 603 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 47:
-#line 606 "grammar.y"
+#line 607 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 48:
-#line 610 "grammar.y"
+#line 611 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
}
break;
case 49:
-#line 614 "grammar.y"
+#line 615 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 50:
-#line 618 "grammar.y"
+#line 619 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 51:
-#line 622 "grammar.y"
+#line 623 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
}
break;
case 52:
-#line 626 "grammar.y"
+#line 627 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 53:
-#line 630 "grammar.y"
+#line 631 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 54:
-#line 634 "grammar.y"
+#line 635 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 55:
-#line 638 "grammar.y"
+#line 639 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 56:
-#line 642 "grammar.y"
+#line 643 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 57:
-#line 646 "grammar.y"
+#line 647 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 58:
-#line 650 "grammar.y"
+#line 651 "grammar.y"
{
Symbol *s;
s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
@@ -2314,13 +2318,13 @@ case 58:
}
break;
case 61:
-#line 662 "grammar.y"
+#line 663 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 62:
-#line 666 "grammar.y"
+#line 667 "grammar.y"
{
/* This rule allows the <pointer> nonterminal to scan #define
* names as if they were type modifiers.
@@ -2332,56 +2336,56 @@ case 62:
}
break;
case 63:
-#line 679 "grammar.y"
+#line 680 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
}
break;
case 64:
-#line 686 "grammar.y"
+#line 687 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 65:
-#line 693 "grammar.y"
+#line 694 "grammar.y"
{
- (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 66:
-#line 701 "grammar.y"
+#line 702 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 67:
-#line 705 "grammar.y"
+#line 706 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 68:
-#line 712 "grammar.y"
+#line 713 "grammar.y"
{
new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
}
break;
case 69:
-#line 716 "grammar.y"
+#line 717 "grammar.y"
{
add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
}
break;
case 70:
-#line 723 "grammar.y"
+#line 724 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -2392,7 +2396,7 @@ case 70:
}
break;
case 71:
-#line 732 "grammar.y"
+#line 733 "grammar.y"
{
if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -2402,42 +2406,42 @@ case 71:
}
break;
case 73:
-#line 744 "grammar.y"
+#line 745 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
}
break;
case 74:
-#line 751 "grammar.y"
+#line 752 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 75:
-#line 758 "grammar.y"
+#line 759 "grammar.y"
{
- (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 76:
-#line 766 "grammar.y"
+#line 767 "grammar.y"
{
imply_typedef("enum");
yyval.text = yystack.l_mark[0].text;
}
break;
case 79:
-#line 779 "grammar.y"
+#line 780 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
- (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-1].text.begin;
@@ -2445,32 +2449,32 @@ case 79:
}
break;
case 81:
-#line 792 "grammar.y"
+#line 793 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
}
break;
case 82:
-#line 796 "grammar.y"
+#line 797 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "(%s)", yyval.declarator->text);
+ (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-2].text.begin;
}
break;
case 83:
-#line 804 "grammar.y"
+#line 805 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
}
break;
case 84:
-#line 811 "grammar.y"
+#line 812 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -2480,7 +2484,7 @@ case 84:
}
break;
case 85:
-#line 819 "grammar.y"
+#line 820 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -2490,28 +2494,28 @@ case 85:
}
break;
case 86:
-#line 830 "grammar.y"
+#line 831 "grammar.y"
{
- (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
+ (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
}
break;
case 87:
-#line 835 "grammar.y"
+#line 836 "grammar.y"
{
- (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
+ (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-2].text.begin;
}
break;
case 88:
-#line 843 "grammar.y"
+#line 844 "grammar.y"
{
strcpy(yyval.text.text, "");
yyval.text.begin = 0L;
}
break;
case 90:
-#line 852 "grammar.y"
+#line 853 "grammar.y"
{
(void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
@@ -2519,132 +2523,132 @@ case 90:
}
break;
case 91:
-#line 858 "grammar.y"
+#line 859 "grammar.y"
{
- (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
+ (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
free(yystack.l_mark[0].decl_spec.text);
}
break;
case 93:
-#line 868 "grammar.y"
+#line 869 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
}
break;
case 94:
-#line 875 "grammar.y"
+#line 876 "grammar.y"
{
new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
}
break;
case 95:
-#line 879 "grammar.y"
+#line 880 "grammar.y"
{
add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
}
break;
case 96:
-#line 886 "grammar.y"
+#line 887 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 97:
-#line 891 "grammar.y"
+#line 892 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 98:
-#line 896 "grammar.y"
+#line 897 "grammar.y"
{
check_untagged(&yystack.l_mark[0].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
}
break;
case 99:
-#line 904 "grammar.y"
+#line 905 "grammar.y"
{
new_ident_list(&yyval.param_list);
}
break;
case 101:
-#line 912 "grammar.y"
+#line 913 "grammar.y"
{
new_ident_list(&yyval.param_list);
add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
}
break;
case 102:
-#line 917 "grammar.y"
+#line 918 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
}
break;
case 103:
-#line 924 "grammar.y"
+#line 925 "grammar.y"
{
yyval.text = yystack.l_mark[0].text;
}
break;
case 104:
-#line 928 "grammar.y"
+#line 929 "grammar.y"
{
#if OPT_LINTLIBRARY
if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
yyval.text = yystack.l_mark[0].text;
} else
#endif
- (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text);
+ (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
}
break;
case 105:
-#line 941 "grammar.y"
+#line 942 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 106:
-#line 945 "grammar.y"
+#line 946 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
- (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-1].text.begin;
}
break;
case 108:
-#line 957 "grammar.y"
+#line 958 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "(%s)", yyval.declarator->text);
+ (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-2].text.begin;
}
break;
case 109:
-#line 965 "grammar.y"
+#line 966 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
}
break;
case 110:
-#line 972 "grammar.y"
+#line 973 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 111:
-#line 976 "grammar.y"
+#line 977 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -2654,7 +2658,7 @@ case 111:
}
break;
case 112:
-#line 984 "grammar.y"
+#line 985 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
@@ -2663,7 +2667,7 @@ case 112:
}
break;
case 113:
-#line 991 "grammar.y"
+#line 992 "grammar.y"
{
Declarator *d;
@@ -2676,7 +2680,7 @@ case 113:
}
break;
case 114:
-#line 1002 "grammar.y"
+#line 1003 "grammar.y"
{
Declarator *d;
@@ -2687,7 +2691,7 @@ case 114:
yyval.declarator->func_def = FUNC_ANSI;
}
break;
-#line 2691 "grammar.tab.c"
+#line 2695 "grammar.tab.c"
default:
break;
}
@@ -2742,12 +2746,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/help.error b/test/btyacc/help.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/btyacc/help.error
+++ b/test/btyacc/help.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/btyacc/help.output b/test/btyacc/help.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/btyacc/help.output
+++ b/test/btyacc/help.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/btyacc/inherit0.tab.c b/test/btyacc/inherit0.tab.c
index 058f6238dd3fa..725e10532a7a6 100644
--- a/test/btyacc/inherit0.tab.c
+++ b/test/btyacc/inherit0.tab.c
@@ -261,13 +261,16 @@ static const char *const inherit0_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -280,17 +283,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -389,7 +392,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 393 "inherit0.tab.c"
+#line 396 "inherit0.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -528,7 +531,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -595,10 +598,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -709,7 +712,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -919,7 +922,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -948,7 +951,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -964,7 +967,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1050,10 +1053,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1103,7 +1106,7 @@ case 11:
#line 43 "inherit0.y"
{ yyval = yystack.l_mark[0]; }
break;
-#line 1107 "inherit0.tab.c"
+#line 1110 "inherit0.tab.c"
default:
break;
}
@@ -1158,12 +1161,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/inherit1.tab.c b/test/btyacc/inherit1.tab.c
index 5ff8f34bd22f1..c51f9327c9d65 100644
--- a/test/btyacc/inherit1.tab.c
+++ b/test/btyacc/inherit1.tab.c
@@ -282,13 +282,16 @@ static const char *const inherit1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -301,17 +304,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -410,7 +413,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 414 "inherit1.tab.c"
+#line 417 "inherit1.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -549,7 +552,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -616,10 +619,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -730,7 +733,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -940,7 +943,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -969,7 +972,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -985,7 +988,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1071,10 +1074,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1128,7 +1131,7 @@ case 11:
#line 71 "inherit1.y"
{ yyval.nlist = yystack.l_mark[0].nlist; }
break;
-#line 1132 "inherit1.tab.c"
+#line 1135 "inherit1.tab.c"
default:
break;
}
@@ -1183,12 +1186,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/inherit2.tab.c b/test/btyacc/inherit2.tab.c
index f06dda4d0130a..d2fa35983c460 100644
--- a/test/btyacc/inherit2.tab.c
+++ b/test/btyacc/inherit2.tab.c
@@ -289,13 +289,16 @@ static const char *const inherit2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -308,17 +311,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -417,7 +420,7 @@ static YYINT *yylexemes = 0;
extern int YYLEX_DECL();
extern void YYERROR_DECL();
-#line 421 "inherit2.tab.c"
+#line 424 "inherit2.tab.c"
/* Release memory associated with symbol. */
#if ! defined YYDESTRUCT_IS_DECLARED
@@ -437,7 +440,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 441 "inherit2.tab.c"
+#line 444 "inherit2.tab.c"
case 264:
#line 30 "inherit2.y"
{
@@ -449,7 +452,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 453 "inherit2.tab.c"
+#line 456 "inherit2.tab.c"
case 265:
#line 30 "inherit2.y"
{
@@ -461,7 +464,7 @@ YYDESTRUCT_DECL()
}
}
break;
-#line 465 "inherit2.tab.c"
+#line 468 "inherit2.tab.c"
}
}
#define YYDESTRUCT_IS_DECLARED 1
@@ -604,7 +607,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -671,10 +674,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -785,7 +788,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -995,7 +998,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1024,7 +1027,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1040,7 +1043,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1126,10 +1129,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1187,7 +1190,7 @@ case 12:
#line 75 "inherit2.y"
{ yyval.nlist = yystack.l_mark[0].nlist; }
break;
-#line 1191 "inherit2.tab.c"
+#line 1194 "inherit2.tab.c"
default:
break;
}
@@ -1242,12 +1245,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/no_b_opt.error b/test/btyacc/no_b_opt.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/btyacc/no_b_opt.error
+++ b/test/btyacc/no_b_opt.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/btyacc/no_b_opt.output b/test/btyacc/no_b_opt.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/btyacc/no_b_opt.output
+++ b/test/btyacc/no_b_opt.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/btyacc/no_b_opt1.error b/test/btyacc/no_b_opt1.error
index e69de29bb2d1d..87286c2661e6f 100644
--- a/test/btyacc/no_b_opt1.error
+++ b/test/btyacc/no_b_opt1.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.c"
diff --git a/test/btyacc/no_b_opt1.output b/test/btyacc/no_b_opt1.output
index 87286c2661e6f..e69de29bb2d1d 100644
--- a/test/btyacc/no_b_opt1.output
+++ b/test/btyacc/no_b_opt1.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.c"
diff --git a/test/btyacc/no_code_c.error b/test/btyacc/no_code_c.error
index e69de29bb2d1d..87286c2661e6f 100644
--- a/test/btyacc/no_code_c.error
+++ b/test/btyacc/no_code_c.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.c"
diff --git a/test/btyacc/no_code_c.output b/test/btyacc/no_code_c.output
index 87286c2661e6f..e69de29bb2d1d 100644
--- a/test/btyacc/no_code_c.output
+++ b/test/btyacc/no_code_c.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.c"
diff --git a/test/btyacc/no_defines.error b/test/btyacc/no_defines.error
index e69de29bb2d1d..773985d66f33c 100644
--- a/test/btyacc/no_defines.error
+++ b/test/btyacc/no_defines.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.h"
diff --git a/test/btyacc/no_defines.output b/test/btyacc/no_defines.output
index 773985d66f33c..e69de29bb2d1d 100644
--- a/test/btyacc/no_defines.output
+++ b/test/btyacc/no_defines.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.h"
diff --git a/test/btyacc/no_graph.error b/test/btyacc/no_graph.error
index e69de29bb2d1d..d5575f4004215 100644
--- a/test/btyacc/no_graph.error
+++ b/test/btyacc/no_graph.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.dot"
diff --git a/test/btyacc/no_graph.output b/test/btyacc/no_graph.output
index d5575f4004215..e69de29bb2d1d 100644
--- a/test/btyacc/no_graph.output
+++ b/test/btyacc/no_graph.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.dot"
diff --git a/test/btyacc/no_include.error b/test/btyacc/no_include.error
index e69de29bb2d1d..3ece4a454e392 100644
--- a/test/btyacc/no_include.error
+++ b/test/btyacc/no_include.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.i"
diff --git a/test/btyacc/no_include.output b/test/btyacc/no_include.output
index 3ece4a454e392..e69de29bb2d1d 100644
--- a/test/btyacc/no_include.output
+++ b/test/btyacc/no_include.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.i"
diff --git a/test/btyacc/no_opts.error b/test/btyacc/no_opts.error
index e69de29bb2d1d..ad3131a69ab68 100644
--- a/test/btyacc/no_opts.error
+++ b/test/btyacc/no_opts.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.y"
diff --git a/test/btyacc/no_opts.output b/test/btyacc/no_opts.output
index ad3131a69ab68..e69de29bb2d1d 100644
--- a/test/btyacc/no_opts.output
+++ b/test/btyacc/no_opts.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.y"
diff --git a/test/btyacc/no_output.error b/test/btyacc/no_output.error
index e69de29bb2d1d..a2f142a9d531a 100644
--- a/test/btyacc/no_output.error
+++ b/test/btyacc/no_output.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.output"
diff --git a/test/btyacc/no_output.output b/test/btyacc/no_output.output
index a2f142a9d531a..e69de29bb2d1d 100644
--- a/test/btyacc/no_output.output
+++ b/test/btyacc/no_output.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.output"
diff --git a/test/btyacc/no_output1.error b/test/btyacc/no_output1.error
index e69de29bb2d1d..a2f142a9d531a 100644
--- a/test/btyacc/no_output1.error
+++ b/test/btyacc/no_output1.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.output"
diff --git a/test/btyacc/no_output1.output b/test/btyacc/no_output1.output
index a2f142a9d531a..e69de29bb2d1d 100644
--- a/test/btyacc/no_output1.output
+++ b/test/btyacc/no_output1.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.output"
diff --git a/test/btyacc/no_output2.error b/test/btyacc/no_output2.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/btyacc/no_output2.error
+++ b/test/btyacc/no_output2.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/btyacc/no_output2.output b/test/btyacc/no_output2.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/btyacc/no_output2.output
+++ b/test/btyacc/no_output2.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/btyacc/no_p_opt.error b/test/btyacc/no_p_opt.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/btyacc/no_p_opt.error
+++ b/test/btyacc/no_p_opt.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/btyacc/no_p_opt.output b/test/btyacc/no_p_opt.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/btyacc/no_p_opt.output
+++ b/test/btyacc/no_p_opt.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/btyacc/no_p_opt1.error b/test/btyacc/no_p_opt1.error
index e69de29bb2d1d..87286c2661e6f 100644
--- a/test/btyacc/no_p_opt1.error
+++ b/test/btyacc/no_p_opt1.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.c"
diff --git a/test/btyacc/no_p_opt1.output b/test/btyacc/no_p_opt1.output
index 87286c2661e6f..e69de29bb2d1d 100644
--- a/test/btyacc/no_p_opt1.output
+++ b/test/btyacc/no_p_opt1.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.c"
diff --git a/test/btyacc/no_verbose.error b/test/btyacc/no_verbose.error
index e69de29bb2d1d..a2f142a9d531a 100644
--- a/test/btyacc/no_verbose.error
+++ b/test/btyacc/no_verbose.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.output"
diff --git a/test/btyacc/no_verbose.output b/test/btyacc/no_verbose.output
index a2f142a9d531a..e69de29bb2d1d 100644
--- a/test/btyacc/no_verbose.output
+++ b/test/btyacc/no_verbose.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.output"
diff --git a/test/btyacc/nostdin.error b/test/btyacc/nostdin.error
index e69de29bb2d1d..67101620d2c1e 100644
--- a/test/btyacc/nostdin.error
+++ b/test/btyacc/nostdin.error
@@ -0,0 +1,19 @@
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/btyacc/nostdin.output b/test/btyacc/nostdin.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/btyacc/nostdin.output
+++ b/test/btyacc/nostdin.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/btyacc/ok_syntax1.tab.c b/test/btyacc/ok_syntax1.tab.c
index 087a3d0c505c4..62662b12d3dc3 100644
--- a/test/btyacc/ok_syntax1.tab.c
+++ b/test/btyacc/ok_syntax1.tab.c
@@ -368,8 +368,9 @@ static const char *const ok_syntax1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
#ifndef YYLLOC_DEFAULT
@@ -378,17 +379,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -495,7 +496,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 499 "ok_syntax1.tab.c"
+#line 500 "ok_syntax1.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -632,6 +633,8 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -684,7 +687,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -760,10 +763,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -874,7 +877,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1084,7 +1087,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1113,7 +1116,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1129,7 +1132,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1215,10 +1218,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1284,7 +1287,7 @@ case 18:
#line 101 "ok_syntax1.y"
{ yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; }
break;
-#line 1288 "ok_syntax1.tab.c"
+#line 1291 "ok_syntax1.tab.c"
default:
break;
}
@@ -1339,12 +1342,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/ok_syntax1.tab.h b/test/btyacc/ok_syntax1.tab.h
index 75e9a96c9bf91..44b8dc3e95d3e 100644
--- a/test/btyacc/ok_syntax1.tab.h
+++ b/test/btyacc/ok_syntax1.tab.h
@@ -30,6 +30,5 @@ typedef union
double dval;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
-extern YYSTYPE ok_syntax1_lval;
#endif /* _ok_syntax1__defines_h_ */
diff --git a/test/btyacc/pure_calc.tab.c b/test/btyacc/pure_calc.tab.c
index 8c9cfce026d87..e48c9744b6f77 100644
--- a/test/btyacc/pure_calc.tab.c
+++ b/test/btyacc/pure_calc.tab.c
@@ -348,8 +348,9 @@ static const char *const calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
#ifndef YYLLOC_DEFAULT
@@ -358,17 +359,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -468,7 +469,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 472 "pure_calc.tab.c"
+#line 473 "pure_calc.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -605,6 +606,8 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -657,7 +660,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -733,10 +736,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -847,7 +850,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1057,7 +1060,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1086,7 +1089,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1102,7 +1105,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1188,10 +1191,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1257,7 +1260,7 @@ case 18:
#line 69 "pure_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1261 "pure_calc.tab.c"
+#line 1264 "pure_calc.tab.c"
default:
break;
}
@@ -1312,12 +1315,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/pure_error.tab.c b/test/btyacc/pure_error.tab.c
index 2c334b5318676..1860f54cc20e8 100644
--- a/test/btyacc/pure_error.tab.c
+++ b/test/btyacc/pure_error.tab.c
@@ -236,8 +236,9 @@ static const char *const error_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
#ifndef YYLLOC_DEFAULT
@@ -246,17 +247,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -336,7 +337,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 340 "pure_error.tab.c"
+#line 341 "pure_error.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -473,6 +474,8 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -525,7 +528,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -601,10 +604,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -715,7 +718,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -925,7 +928,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -954,7 +957,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -970,7 +973,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1056,10 +1059,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1119,12 +1122,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc-s.tab.c b/test/btyacc/quote_calc-s.tab.c
index 25305be1e8087..ddef2f7672fb0 100644
--- a/test/btyacc/quote_calc-s.tab.c
+++ b/test/btyacc/quote_calc-s.tab.c
@@ -357,13 +357,16 @@ static const char *const quote_calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -376,17 +379,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -522,7 +525,7 @@ yylex(void) {
}
return( c );
}
-#line 526 "quote_calc-s.tab.c"
+#line 529 "quote_calc-s.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -661,7 +664,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -728,10 +731,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -842,7 +845,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1052,7 +1055,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1081,7 +1084,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1097,7 +1100,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1183,10 +1186,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1252,7 +1255,7 @@ case 18:
#line 70 "quote_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1256 "quote_calc-s.tab.c"
+#line 1259 "quote_calc-s.tab.c"
default:
break;
}
@@ -1307,12 +1310,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc.tab.c b/test/btyacc/quote_calc.tab.c
index 092129c038a04..95f023cc545ae 100644
--- a/test/btyacc/quote_calc.tab.c
+++ b/test/btyacc/quote_calc.tab.c
@@ -363,13 +363,16 @@ static const char *const quote_calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -382,17 +385,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -528,7 +531,7 @@ yylex(void) {
}
return( c );
}
-#line 532 "quote_calc.tab.c"
+#line 535 "quote_calc.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -667,7 +670,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -734,10 +737,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -848,7 +851,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1058,7 +1061,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1087,7 +1090,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1103,7 +1106,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1189,10 +1192,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1258,7 +1261,7 @@ case 18:
#line 70 "quote_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1262 "quote_calc.tab.c"
+#line 1265 "quote_calc.tab.c"
default:
break;
}
@@ -1313,12 +1316,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc2-s.tab.c b/test/btyacc/quote_calc2-s.tab.c
index fb14a9524c863..de64730474d4f 100644
--- a/test/btyacc/quote_calc2-s.tab.c
+++ b/test/btyacc/quote_calc2-s.tab.c
@@ -357,13 +357,16 @@ static const char *const quote_calc2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -376,17 +379,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -522,7 +525,7 @@ yylex(void) {
}
return( c );
}
-#line 526 "quote_calc2-s.tab.c"
+#line 529 "quote_calc2-s.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -661,7 +664,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -728,10 +731,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -842,7 +845,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1052,7 +1055,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1081,7 +1084,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1097,7 +1100,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1183,10 +1186,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1252,7 +1255,7 @@ case 18:
#line 70 "quote_calc2.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1256 "quote_calc2-s.tab.c"
+#line 1259 "quote_calc2-s.tab.c"
default:
break;
}
@@ -1307,12 +1310,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc2.tab.c b/test/btyacc/quote_calc2.tab.c
index f9832043bee6d..cfd7d7f7329a4 100644
--- a/test/btyacc/quote_calc2.tab.c
+++ b/test/btyacc/quote_calc2.tab.c
@@ -363,13 +363,16 @@ static const char *const quote_calc2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -382,17 +385,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -528,7 +531,7 @@ yylex(void) {
}
return( c );
}
-#line 532 "quote_calc2.tab.c"
+#line 535 "quote_calc2.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -667,7 +670,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -734,10 +737,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -848,7 +851,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1058,7 +1061,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1087,7 +1090,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1103,7 +1106,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1189,10 +1192,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1258,7 +1261,7 @@ case 18:
#line 70 "quote_calc2.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1262 "quote_calc2.tab.c"
+#line 1265 "quote_calc2.tab.c"
default:
break;
}
@@ -1313,12 +1316,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc3-s.tab.c b/test/btyacc/quote_calc3-s.tab.c
index 15fbd67e18edb..235dc8d148189 100644
--- a/test/btyacc/quote_calc3-s.tab.c
+++ b/test/btyacc/quote_calc3-s.tab.c
@@ -358,13 +358,16 @@ static const char *const quote_calc3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -377,17 +380,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -523,7 +526,7 @@ yylex(void) {
}
return( c );
}
-#line 527 "quote_calc3-s.tab.c"
+#line 530 "quote_calc3-s.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -662,7 +665,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -729,10 +732,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -843,7 +846,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1053,7 +1056,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1082,7 +1085,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1098,7 +1101,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1184,10 +1187,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1253,7 +1256,7 @@ case 18:
#line 70 "quote_calc3.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1257 "quote_calc3-s.tab.c"
+#line 1260 "quote_calc3-s.tab.c"
default:
break;
}
@@ -1308,12 +1311,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc3.tab.c b/test/btyacc/quote_calc3.tab.c
index ef26f74d9de5f..16daf6a6ede5a 100644
--- a/test/btyacc/quote_calc3.tab.c
+++ b/test/btyacc/quote_calc3.tab.c
@@ -358,13 +358,16 @@ static const char *const quote_calc3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -377,17 +380,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -523,7 +526,7 @@ yylex(void) {
}
return( c );
}
-#line 527 "quote_calc3.tab.c"
+#line 530 "quote_calc3.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -662,7 +665,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -729,10 +732,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -843,7 +846,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1053,7 +1056,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1082,7 +1085,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1098,7 +1101,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1184,10 +1187,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1253,7 +1256,7 @@ case 18:
#line 70 "quote_calc3.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1257 "quote_calc3.tab.c"
+#line 1260 "quote_calc3.tab.c"
default:
break;
}
@@ -1308,12 +1311,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc4-s.tab.c b/test/btyacc/quote_calc4-s.tab.c
index a5ebdbc3cbc64..b3266cf6842f1 100644
--- a/test/btyacc/quote_calc4-s.tab.c
+++ b/test/btyacc/quote_calc4-s.tab.c
@@ -358,13 +358,16 @@ static const char *const quote_calc4_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -377,17 +380,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -523,7 +526,7 @@ yylex(void) {
}
return( c );
}
-#line 527 "quote_calc4-s.tab.c"
+#line 530 "quote_calc4-s.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -662,7 +665,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -729,10 +732,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -843,7 +846,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1053,7 +1056,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1082,7 +1085,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1098,7 +1101,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1184,10 +1187,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1253,7 +1256,7 @@ case 18:
#line 70 "quote_calc4.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1257 "quote_calc4-s.tab.c"
+#line 1260 "quote_calc4-s.tab.c"
default:
break;
}
@@ -1308,12 +1311,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/quote_calc4.tab.c b/test/btyacc/quote_calc4.tab.c
index 14ed4ed06493c..1950fd842bc0c 100644
--- a/test/btyacc/quote_calc4.tab.c
+++ b/test/btyacc/quote_calc4.tab.c
@@ -358,13 +358,16 @@ static const char *const quote_calc4_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -377,17 +380,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -523,7 +526,7 @@ yylex(void) {
}
return( c );
}
-#line 527 "quote_calc4.tab.c"
+#line 530 "quote_calc4.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -662,7 +665,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -729,10 +732,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -843,7 +846,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1053,7 +1056,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1082,7 +1085,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1098,7 +1101,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1184,10 +1187,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1253,7 +1256,7 @@ case 18:
#line 70 "quote_calc4.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 1257 "quote_calc4.tab.c"
+#line 1260 "quote_calc4.tab.c"
default:
break;
}
@@ -1308,12 +1311,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/rename_debug.c b/test/btyacc/rename_debug.c
index 5681f91930fd9..2c7986e3003e5 100644
--- a/test/btyacc/rename_debug.c
+++ b/test/btyacc/rename_debug.c
@@ -83,13 +83,16 @@ static const char *const yyrule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -102,17 +105,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -233,7 +236,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 238 "rename_debug.c"
+#line 241 "rename_debug.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -372,7 +375,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -439,10 +442,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -553,7 +556,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -763,7 +766,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -792,7 +795,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -808,7 +811,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -894,10 +897,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -957,12 +960,12 @@ yyreduce:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/btyacc/rename_debug.i b/test/btyacc/rename_debug.i
index b8f2144e197f3..ce4871a0e68f4 100644
--- a/test/btyacc/rename_debug.i
+++ b/test/btyacc/rename_debug.i
@@ -37,6 +37,10 @@ typedef int YYSTYPE;
# define YYLEX yylex()
#endif
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
@@ -47,13 +51,20 @@ typedef int YYSTYPE;
extern int YYPARSE_DECL();
+#ifndef YYDEBUG
+#define YYDEBUG 1
+#endif
+
+#if YYDEBUG
extern int yydebug;
-extern int yynerrs;
+#endif
extern int yyerrflag;
extern int yychar;
extern YYSTYPE yyval;
extern YYSTYPE yylval;
+extern int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
extern YYLTYPE yyloc; /* position returned by actions */
extern YYLTYPE yylloc; /* position from the lexer */
diff --git a/test/btyacc/stdin1.calc.c b/test/btyacc/stdin1.calc.c
new file mode 100644
index 0000000000000..b1dab7214fcb6
--- /dev/null
+++ b/test/btyacc/stdin1.calc.c
@@ -0,0 +1,1381 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "(null)"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 34 "stdin1.calc.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT yystos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT yycindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT yyctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+#line 66 "(null)"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 418 "stdin1.calc.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "(null)"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "(null)"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "(null)"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "(null)"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "(null)"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "(null)"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "(null)"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "(null)"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "(null)"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "(null)"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "(null)"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "(null)"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "(null)"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "(null)"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "(null)"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1148 "stdin1.calc.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/stdin1.error b/test/btyacc/stdin1.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/stdin1.error
diff --git a/test/btyacc/stdin1.output b/test/btyacc/stdin1.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/stdin1.output
diff --git a/test/btyacc/stdin2.calc.c b/test/btyacc/stdin2.calc.c
new file mode 100644
index 0000000000000..bf84b59779ef6
--- /dev/null
+++ b/test/btyacc/stdin2.calc.c
@@ -0,0 +1,1381 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#undef YYBTYACC
+#define YYBTYACC 0
+#define YYDEBUGSTR YYPREFIX "debug"
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 34 "stdin2.calc.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
+static const YYINT yystos[] = { 0,
+ 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
+ 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
+ 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
+ 263, 263,
+};
+#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+#if YYBTYACC
+static const YYINT yycindex[] = { 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, 0, 0, 0, 0,
+ 0, 0,
+};
+#endif
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#if YYBTYACC
+static const YYINT yyctable[] = { -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, -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, -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,
+ -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, -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, -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, -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, -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, -1, -1, -1, -1,
+};
+#endif
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"$end",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
+"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+YYLTYPE yyloc; /* position returned by actions */
+YYLTYPE yylloc; /* position from the lexer */
+#endif
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+#ifndef YYLLOC_DEFAULT
+#define YYLLOC_DEFAULT(loc, rhs, n) \
+do \
+{ \
+ if (n == 0) \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
+ } \
+ else \
+ { \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
+ } \
+} while (0)
+#endif /* YYLLOC_DEFAULT */
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#if YYBTYACC
+
+#ifndef YYLVQUEUEGROWTH
+#define YYLVQUEUEGROWTH 32
+#endif
+#endif /* YYBTYACC */
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#ifndef YYINITSTACKSIZE
+#define YYINITSTACKSIZE 200
+#endif
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *p_base;
+ YYLTYPE *p_mark;
+#endif
+} YYSTACKDATA;
+#if YYBTYACC
+
+struct YYParseState_s
+{
+ struct YYParseState_s *save; /* Previously saved parser state */
+ YYSTACKDATA yystack; /* saved parser stack */
+ int state; /* saved parser state */
+ int errflag; /* saved error recovery status */
+ int lexeme; /* saved index of the conflict lexeme in the lexical queue */
+ YYINT ctry; /* saved index in yyctable[] for this conflict */
+};
+typedef struct YYParseState_s YYParseState;
+#endif /* YYBTYACC */
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#if YYBTYACC
+
+/* Current parser state */
+static YYParseState *yyps = 0;
+
+/* yypath != NULL: do the full parse, starting at *yypath parser state. */
+static YYParseState *yypath = 0;
+
+/* Base of the lexical value queue */
+static YYSTYPE *yylvals = 0;
+
+/* Current position at lexical value queue */
+static YYSTYPE *yylvp = 0;
+
+/* End position of lexical value queue */
+static YYSTYPE *yylve = 0;
+
+/* The last allocated position at the lexical value queue */
+static YYSTYPE *yylvlim = 0;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+/* Base of the lexical position queue */
+static YYLTYPE *yylpsns = 0;
+
+/* Current position at lexical position queue */
+static YYLTYPE *yylpp = 0;
+
+/* End position of lexical position queue */
+static YYLTYPE *yylpe = 0;
+
+/* The last allocated position at the lexical position queue */
+static YYLTYPE *yylplim = 0;
+#endif
+
+/* Current position at lexical token queue */
+static YYINT *yylexp = 0;
+
+static YYINT *yylexemes = 0;
+#endif /* YYBTYACC */
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 418 "stdin2.calc.c"
+
+/* For use in generated program */
+#define yydepth (int)(yystack.s_mark - yystack.s_base)
+#if YYBTYACC
+#define yytrial (yyps->save)
+#endif /* YYBTYACC */
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *newps;
+#endif
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
+ if (newps == 0)
+ return YYENOMEM;
+
+ data->p_base = newps;
+ data->p_mark = newps + i;
+#endif
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
+#endif
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ free(data->p_base);
+#endif
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif /* YYPURE || defined(YY_NO_LEAKS) */
+#if YYBTYACC
+
+static YYParseState *
+yyNewState(unsigned size)
+{
+ YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
+ if (p == NULL) return NULL;
+
+ p->yystack.stacksize = size;
+ if (size == 0)
+ {
+ p->yystack.s_base = NULL;
+ p->yystack.l_base = NULL;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = NULL;
+#endif
+ return p;
+ }
+ p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
+ if (p->yystack.s_base == NULL) return NULL;
+ p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
+ if (p->yystack.l_base == NULL) return NULL;
+ memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
+ if (p->yystack.p_base == NULL) return NULL;
+ memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
+#endif
+
+ return p;
+}
+
+static void
+yyFreeState(YYParseState *p)
+{
+ yyfreestack(&p->yystack);
+ free(p);
+}
+#endif /* YYBTYACC */
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+#if YYBTYACC
+#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
+#define YYVALID_NESTED do { if (yyps->save && \
+ yyps->save->save == 0) goto yyvalid; } while(0)
+#endif /* YYBTYACC */
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate, yyresult;
+#if YYBTYACC
+ int yynewerrflag;
+ YYParseState *yyerrctx = NULL;
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
+#endif
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+ if (yydebug)
+ fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
+#endif
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
+#endif
+
+#if YYBTYACC
+ yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
+ yyps->save = 0;
+#endif /* YYBTYACC */
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base;
+#endif
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ }
+#if YYBTYACC
+
+ /* Do we have a conflict? */
+ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ YYINT ctry;
+
+ if (yypath)
+ {
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
+ YYDEBUGSTR, yydepth, yystate);
+#endif
+ /* Switch to the next conflict context */
+ save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ ctry = save->ctry;
+ if (save->state != yystate) YYABORT;
+ yyFreeState(save);
+
+ }
+ else
+ {
+
+ /* Unresolved conflict - start/continue trial parse */
+ YYParseState *save;
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
+ if (yyps->save)
+ fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
+ else
+ fputs("Starting trial parse.\n", stderr);
+ }
+#endif
+ save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (save == NULL) goto yyenomem;
+ save->save = yyps->save;
+ save->state = yystate;
+ save->errflag = yyerrflag;
+ save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = yytable[yyn];
+ if (yyctable[ctry] == -1)
+ {
+#if YYDEBUG
+ if (yydebug && yychar >= YYEOF)
+ fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
+#endif
+ ctry++;
+ }
+ save->ctry = ctry;
+ if (yyps->save == NULL)
+ {
+ /* If this is a first conflict in the stack, start saving lexemes */
+ if (!yylexemes)
+ {
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ if (yylexemes == NULL) goto yyenomem;
+ yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
+ if (yylvals == NULL) goto yyenomem;
+ yylvlim = yylvals + YYLVQUEUEGROWTH;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
+ if (yylpsns == NULL) goto yyenomem;
+ yylplim = yylpsns + YYLVQUEUEGROWTH;
+#endif
+ }
+ if (yylvp == yylve)
+ {
+ yylvp = yylve = yylvals;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns;
+#endif
+ yylexp = yylexemes;
+ if (yychar >= YYEOF)
+ {
+ *yylve++ = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpe++ = yylloc;
+#endif
+ *yylexp = (YYINT) yychar;
+ yychar = YYEMPTY;
+ }
+ }
+ }
+ if (yychar >= YYEOF)
+ {
+ yylvp--;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp--;
+#endif
+ yylexp--;
+ yychar = YYEMPTY;
+ }
+ save->lexeme = (int) (yylvp - yylvals);
+ yyps->save = save;
+ }
+ if (yytable[yyn] == ctry)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
+#endif
+ if (yychar < 0)
+ {
+ yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp++;
+#endif
+ yylexp++;
+ }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
+ goto yyoverflow;
+ yystate = yyctable[ctry];
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ else
+ {
+ yyn = yyctable[ctry];
+ goto yyreduce;
+ }
+ } /* End of code dealing with conflicts */
+#endif /* YYBTYACC */
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
+ YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yylloc;
+#endif
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+#if YYBTYACC
+
+ yynewerrflag = 1;
+ goto yyerrhandler;
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+
+yyerrlab:
+ /* explicit YYERROR from an action -- pop the rhs of the rule reduced
+ * before looking for error recovery */
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+
+ yynewerrflag = 0;
+yyerrhandler:
+ while (yyps->save)
+ {
+ int ctry;
+ YYParseState *save = yyps->save;
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yyps->save->state,
+ (int)(yylvp - yylvals - yyps->save->lexeme));
+#endif
+ /* Memorize most forward-looking error state in case it's really an error. */
+ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
+ {
+ /* Free old saved error context state */
+ if (yyerrctx) yyFreeState(yyerrctx);
+ /* Create and fill out new saved error context state */
+ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
+ if (yyerrctx == NULL) goto yyenomem;
+ yyerrctx->save = yyps->save;
+ yyerrctx->state = yystate;
+ yyerrctx->errflag = yyerrflag;
+ yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
+ memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
+ memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
+ memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yyerrctx->lexeme = (int) (yylvp - yylvals);
+ }
+ yylvp = yylvals + save->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + save->lexeme;
+#endif
+ yylexp = yylexemes + save->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
+ memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
+ memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
+ memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ ctry = ++save->ctry;
+ yystate = save->state;
+ /* We tried shift, try reduce now */
+ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
+ yyps->save = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+
+ /* Nothing left on the stack -- error */
+ if (!yyps->save)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
+ YYPREFIX, yydepth);
+#endif
+ /* Restore state as it was in the most forward-advanced error */
+ yylvp = yylvals + yyerrctx->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yyerrctx->lexeme;
+#endif
+ yylexp = yylexemes + yyerrctx->lexeme;
+ yychar = yylexp[-1];
+ yylval = yylvp[-1];
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = yylpp[-1];
+#endif
+ yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
+ memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
+ memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
+ memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yyerrctx->state;
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yynewerrflag = 1;
+ }
+ if (yynewerrflag == 0) goto yyinrecovery;
+#endif /* YYBTYACC */
+
+ YYERROR_CALL("syntax error");
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
+#endif
+
+#if !YYBTYACC
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+#endif
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* lookahead position is error end position */
+ yyerror_loc_range[2] = yylloc;
+ YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
+ YYDEBUGSTR, yydepth, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ /* the current TOS position is the error start position */
+ yyerror_loc_range[1] = *yystack.p_mark;
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
+#else
+ YYDESTRUCT_CALL("error: discarding state",
+ yystos[*yystack.s_mark], yystack.l_mark);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ --yystack.s_mark;
+ --yystack.l_mark;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ --yystack.p_mark;
+#endif
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
+ YYDEBUGSTR, yydepth, yystate, yychar, yys);
+ }
+#endif
+#if defined(YYDESTRUCT_CALL)
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+#endif /* defined(YYDESTRUCT_CALL) */
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+ yym = yylen[yyn];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
+ YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ if (yym > 0)
+ {
+ int i;
+ fputc('<', stderr);
+ for (i = yym; i > 0; i--)
+ {
+ if (i != yym) fputs(", ", stderr);
+ fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
+ yystack.l_mark[1-i]), stderr);
+ }
+ fputc('>', stderr);
+ }
+#endif
+ fputc('\n', stderr);
+ }
+#endif
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+
+ /* Perform position reduction */
+ memset(&yyloc, 0, sizeof(yyloc));
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ {
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
+ /* just in case YYERROR is invoked within the action, save
+ the start of the rhs as the error start position */
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
+ }
+#endif
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 1148 "stdin2.calc.c"
+ default:
+ break;
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark -= yym;
+#endif
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
+#endif
+ fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
+ }
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ if (yychar < 0)
+ {
+#if YYBTYACC
+ do {
+ if (yylvp < yylve)
+ {
+ /* we're currently re-reading tokens */
+ yylval = *yylvp++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylloc = *yylpp++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ if (yyps->save)
+ {
+ /* in trial mode; save scanner results for future parse attempts */
+ if (yylvp == yylvlim)
+ { /* Enlarge lexical value queue */
+ size_t p = (size_t) (yylvp - yylvals);
+ size_t s = (size_t) (yylvlim - yylvals);
+
+ s += YYLVQUEUEGROWTH;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ goto yyenomem;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ goto yyenomem;
+#endif
+ yylvp = yylve = yylvals + p;
+ yylvlim = yylvals + s;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpe = yylpsns + p;
+ yylplim = yylpsns + s;
+#endif
+ yylexp = yylexemes + p;
+ }
+ *yylexp = (YYINT) YYLEX;
+ *yylvp++ = yylval;
+ yylve++;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *yylpp++ = yylloc;
+ yylpe++;
+#endif
+ yychar = *yylexp++;
+ break;
+ }
+ /* normal operation, no conflict encountered */
+#endif /* YYBTYACC */
+ yychar = YYLEX;
+#if YYBTYACC
+ } while (0);
+#endif /* YYBTYACC */
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
+ YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ {
+ fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
+#ifdef YYSTYPE_TOSTRING
+#if YYBTYACC
+ if (!yytrial)
+#endif /* YYBTYACC */
+ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
+#endif
+ fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
+ }
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ *++yystack.p_mark = yyloc;
+#endif
+ goto yyloop;
+#if YYBTYACC
+
+ /* Reduction declares that this path is valid. Set yypath and do a full parse */
+yyvalid:
+ if (yypath) YYABORT;
+ while (yyps->save)
+ {
+ YYParseState *save = yyps->save;
+ yyps->save = save->save;
+ save->save = yypath;
+ yypath = save;
+ }
+#if YYDEBUG
+ if (yydebug)
+ fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
+ YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
+#endif
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ yylvp = yylvals + yypath->lexeme;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yylpp = yylpsns + yypath->lexeme;
+#endif
+ yylexp = yylexemes + yypath->lexeme;
+ yychar = YYEMPTY;
+ yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
+ memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
+ yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
+ memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
+ memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
+#endif
+ yystate = yypath->state;
+ goto yyloop;
+#endif /* YYBTYACC */
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+#if YYBTYACC
+ goto yyabort_nomem;
+yyenomem:
+ YYERROR_CALL("memory exhausted");
+yyabort_nomem:
+#endif /* YYBTYACC */
+ yyresult = 2;
+ goto yyreturn;
+
+yyabort:
+ yyresult = 1;
+ goto yyreturn;
+
+yyaccept:
+#if YYBTYACC
+ if (yyps->save) goto yyvalid;
+#endif /* YYBTYACC */
+ yyresult = 0;
+
+yyreturn:
+#if defined(YYDESTRUCT_CALL)
+ if (yychar != YYEOF && yychar != YYEMPTY)
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
+#else
+ YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+
+ {
+ YYSTYPE *pv;
+#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+ YYLTYPE *pp;
+
+ for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
+#else
+ for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
+ YYDESTRUCT_CALL("cleanup: discarding state",
+ yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
+#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
+ }
+#endif /* defined(YYDESTRUCT_CALL) */
+
+#if YYBTYACC
+ if (yyerrctx)
+ {
+ yyFreeState(yyerrctx);
+ yyerrctx = NULL;
+ }
+ while (yyps)
+ {
+ YYParseState *save = yyps;
+ yyps = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+ while (yypath)
+ {
+ YYParseState *save = yypath;
+ yypath = save->save;
+ save->save = NULL;
+ yyFreeState(save);
+ }
+#endif /* YYBTYACC */
+ yyfreestack(&yystack);
+ return (yyresult);
+}
diff --git a/test/btyacc/stdin2.error b/test/btyacc/stdin2.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/stdin2.error
diff --git a/test/btyacc/stdin2.output b/test/btyacc/stdin2.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/btyacc/stdin2.output
diff --git a/test/btyacc/varsyntax_calc1.tab.c b/test/btyacc/varsyntax_calc1.tab.c
index 3f37ddff336e8..bd2bdd506b24c 100644
--- a/test/btyacc/varsyntax_calc1.tab.c
+++ b/test/btyacc/varsyntax_calc1.tab.c
@@ -394,13 +394,16 @@ static const char *const varsyntax_calc1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
+
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE yyloc; /* position returned by actions */
YYLTYPE yylloc; /* position from the lexer */
@@ -413,17 +416,17 @@ do \
{ \
if (n == 0) \
{ \
- (loc).first_line = ((rhs)[-1]).last_line; \
- (loc).first_column = ((rhs)[-1]).last_column; \
- (loc).last_line = ((rhs)[-1]).last_line; \
- (loc).last_column = ((rhs)[-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
} \
else \
{ \
- (loc).first_line = ((rhs)[ 0 ]).first_line; \
- (loc).first_column = ((rhs)[ 0 ]).first_column; \
- (loc).last_line = ((rhs)[n-1]).last_line; \
- (loc).last_column = ((rhs)[n-1]).last_column; \
+ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+ (loc).last_line = YYRHSLOC(rhs, n).last_line; \
+ (loc).last_column = YYRHSLOC(rhs, n).last_column; \
} \
} while (0)
#endif /* YYLLOC_DEFAULT */
@@ -649,7 +652,7 @@ vdiv(double a, double b, INTERVAL v)
{
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
}
-#line 653 "varsyntax_calc1.tab.c"
+#line 656 "varsyntax_calc1.tab.c"
/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
@@ -788,7 +791,7 @@ YYPARSE_DECL()
YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
+ YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
const char *yys;
@@ -855,10 +858,10 @@ yyloop:
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
@@ -969,7 +972,7 @@ yyloop:
/* If this is a first conflict in the stack, start saving lexemes */
if (!yylexemes)
{
- yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
+ yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
if (yylexemes == NULL) goto yyenomem;
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
if (yylvals == NULL) goto yyenomem;
@@ -1179,7 +1182,7 @@ yyerrhandler:
YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+ yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif
#if !YYBTYACC
@@ -1208,7 +1211,7 @@ yyinrecovery:
*++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* lookahead position is error end position */
- yyerror_loc_range[1] = yylloc;
+ yyerror_loc_range[2] = yylloc;
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
*++yystack.p_mark = yyloc;
#endif
@@ -1224,7 +1227,7 @@ yyinrecovery:
if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* the current TOS position is the error start position */
- yyerror_loc_range[0] = *yystack.p_mark;
+ yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
@@ -1310,10 +1313,10 @@ yyreduce:
if (!yytrial)
#endif /* YYBTYACC */
{
- YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
+ YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
/* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
- yyerror_loc_range[0] = yystack.p_mark[1-yym];
+ yyerror_loc_range[1] = yystack.p_mark[1-yym];
}
#endif
@@ -1482,7 +1485,7 @@ case 28:
yyval.vval = yystack.l_mark[-1].vval;
}
break;
-#line 1486 "varsyntax_calc1.tab.c"
+#line 1489 "varsyntax_calc1.tab.c"
default:
break;
}
@@ -1537,12 +1540,12 @@ break;
size_t s = (size_t) (yylvlim - yylvals);
s += YYLVQUEUEGROWTH;
- if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
+ if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
goto yyenomem;
- if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
+ if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
+ if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
goto yyenomem;
#endif
yylvp = yylve = yylvals + p;
diff --git a/test/calc.tab.c b/test/calc.tab.c
new file mode 100644
index 0000000000000..1f3a81f58dbce
--- /dev/null
+++ b/test/calc.tab.c
@@ -0,0 +1,668 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse calc_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "calc.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+static const short calc_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short calc_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short calc_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const short calc_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short calc_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const short calc_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const short calc_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const short calc_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const short calc_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? (YYMAXTOKEN + 1) : (a))
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS","illegal-symbol",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 347 "calc.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = yyname[YYTRANSLATE(yychar)];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = yyname[YYTRANSLATE(yychar)];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 609 "calc.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = yyname[YYTRANSLATE(yychar)];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/calc_code_all.y b/test/calc_code_all.y
new file mode 100644
index 0000000000000..5924877f158e6
--- /dev/null
+++ b/test/calc_code_all.y
@@ -0,0 +1,113 @@
+%code { /* CODE-DEFAULT2 */ }
+%code { /* CODE-DEFAULT */ }
+%code requires { /* CODE-REQUIRES */ }
+%code provides { /* CODE-PROVIDES */ }
+%code top { /* CODE-TOP */ }
+%code provides { /* CODE-PROVIDES2 */ }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/calc_code_default.y b/test/calc_code_default.y
new file mode 100644
index 0000000000000..a0829affbe3d7
--- /dev/null
+++ b/test/calc_code_default.y
@@ -0,0 +1,109 @@
+%code { /* CODE-DEFAULT */ }
+%code { /* CODE-DEFAULT2 */ }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/calc_code_imports.y b/test/calc_code_imports.y
new file mode 100644
index 0000000000000..ded30926f7b31
--- /dev/null
+++ b/test/calc_code_imports.y
@@ -0,0 +1,109 @@
+%code imports { /* CODE-IMPORTS */ }
+%code imports { /* CODE-IMPORTS2 */ }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/calc_code_provides.y b/test/calc_code_provides.y
new file mode 100644
index 0000000000000..53776928dcda2
--- /dev/null
+++ b/test/calc_code_provides.y
@@ -0,0 +1,109 @@
+%code provides { /* CODE-PROVIDES */ }
+%code provides { /* CODE-PROVIDES2 */ }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/calc_code_requires.y b/test/calc_code_requires.y
new file mode 100644
index 0000000000000..5254bcbd6de0d
--- /dev/null
+++ b/test/calc_code_requires.y
@@ -0,0 +1,109 @@
+%code requires { /* CODE-REQUIRES */ }
+%code requires { /* CODE-REQUIRES2 */ }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/calc_code_top.y b/test/calc_code_top.y
new file mode 100644
index 0000000000000..8520791e4defc
--- /dev/null
+++ b/test/calc_code_top.y
@@ -0,0 +1,109 @@
+%code top { /* CODE-TOP */ }
+%code top { /* CODE-TOP2 */ }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/grammar.y b/test/grammar.y
index 6755522683701..c4c8fd5809309 100644
--- a/test/grammar.y
+++ b/test/grammar.y
@@ -1,4 +1,4 @@
-/* $Id: grammar.y,v 1.5 2012/01/15 20:00:59 tom Exp $
+/* $Id: grammar.y,v 1.7 2020/03/30 23:55:49 tom Exp $
*
* yacc grammar for C function prototype generator
* This was derived from the grammar in Appendix A of
@@ -94,6 +94,7 @@ static void yyerror(const char *s);
/* #include "cproto.h" */
#define MAX_TEXT_SIZE 1024
+#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3)
/* Prototype styles */
#if OPT_LINTLIBRARY
@@ -679,19 +680,19 @@ struct_or_union_specifier
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s %s", $1.text, $2.text);
+ (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text);
new_decl_spec(&$$, s, $1.begin, DS_NONE);
}
| struct_or_union braces
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s {}", $1.text);
+ (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text);
new_decl_spec(&$$, s, $1.begin, DS_NONE);
}
| struct_or_union any_id
{
- (void)sprintf(buf, "%s %s", $1.text, $2.text);
+ (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text);
new_decl_spec(&$$, buf, $1.begin, DS_NONE);
}
;
@@ -744,19 +745,19 @@ enum_specifier
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "enum %s", $2.text);
+ (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, $2.text);
new_decl_spec(&$$, s, $1.begin, DS_NONE);
}
| enumeration braces
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s {}", $1.text);
+ (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text);
new_decl_spec(&$$, s, $1.begin, DS_NONE);
}
| enumeration any_id
{
- (void)sprintf(buf, "enum %s", $2.text);
+ (void)sprintf(buf, "enum %.*s", TEXT_LEN, $2.text);
new_decl_spec(&$$, buf, $1.begin, DS_NONE);
}
;
@@ -778,7 +779,7 @@ declarator
: pointer direct_declarator
{
$$ = $2;
- (void)sprintf(buf, "%s%s", $1.text, $$->text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text);
free($$->text);
$$->text = xstrdup(buf);
$$->begin = $1.begin;
@@ -795,7 +796,7 @@ direct_declarator
| '(' declarator ')'
{
$$ = $2;
- (void)sprintf(buf, "(%s)", $$->text);
+ (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text);
free($$->text);
$$->text = xstrdup(buf);
$$->begin = $1.begin;
@@ -803,7 +804,7 @@ direct_declarator
| direct_declarator T_BRACKETS
{
$$ = $1;
- (void)sprintf(buf, "%s%s", $$->text, $2.text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text);
free($$->text);
$$->text = xstrdup(buf);
}
@@ -828,12 +829,12 @@ direct_declarator
pointer
: '*' opt_type_qualifiers
{
- (void)sprintf($$.text, "*%s", $2.text);
+ (void)sprintf($$.text, "*%.*s", TEXT_LEN, $2.text);
$$.begin = $1.begin;
}
| '*' opt_type_qualifiers pointer
{
- (void)sprintf($$.text, "*%s%s", $2.text, $3.text);
+ (void)sprintf($$.text, "*%.*s%.*s", TEXT_LEN, $2.text, TEXT_LEN, $3.text);
$$.begin = $1.begin;
}
;
@@ -856,7 +857,7 @@ type_qualifier_list
}
| type_qualifier_list type_qualifier
{
- (void)sprintf($$.text, "%s%s ", $1.text, $2.text);
+ (void)sprintf($$.text, "%.*s%.*s ", TEXT_LEN, $1.text, TEXT_LEN, $2.text);
$$.begin = $1.begin;
free($2.text);
}
@@ -931,7 +932,7 @@ identifier_or_ref
$$ = $2;
} else
#endif
- (void)sprintf($$.text, "&%s", $2.text);
+ (void)sprintf($$.text, "&%.*s", TEXT_LEN, $2.text);
$$.begin = $1.begin;
}
;
@@ -944,7 +945,7 @@ abs_declarator
| pointer direct_abs_declarator
{
$$ = $2;
- (void)sprintf(buf, "%s%s", $1.text, $$->text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text);
free($$->text);
$$->text = xstrdup(buf);
$$->begin = $1.begin;
@@ -956,7 +957,7 @@ direct_abs_declarator
: '(' abs_declarator ')'
{
$$ = $2;
- (void)sprintf(buf, "(%s)", $$->text);
+ (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text);
free($$->text);
$$->text = xstrdup(buf);
$$->begin = $1.begin;
@@ -964,7 +965,7 @@ direct_abs_declarator
| direct_abs_declarator T_BRACKETS
{
$$ = $1;
- (void)sprintf(buf, "%s%s", $$->text, $2.text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text);
free($$->text);
$$->text = xstrdup(buf);
}
@@ -1027,7 +1028,7 @@ extern char *yytext;
extern FILE *yyin, *yyout;
static int curly; /* number of curly brace nesting levels */
-static int ly_count; /* number of occurances of %% */
+static int ly_count; /* number of occurrences of %% */
static int inc_depth; /* include nesting level */
static SymbolTable *included_files; /* files already included */
static int yy_start = 0; /* start state number */
diff --git a/test/run_make.sh b/test/run_make.sh
index 3035eb4274e67..77cf633fa9aa1 100755
--- a/test/run_make.sh
+++ b/test/run_make.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: run_make.sh,v 1.15 2016/06/01 22:56:37 Tom.Shields Exp $
+# $Id: run_make.sh,v 1.18 2019/11/25 23:23:26 tom Exp $
# vi:ts=4 sw=4:
# do a test-compile on each of the ".c" files in the test-directory
@@ -97,7 +97,7 @@ then
case $input in
${TEST_DIR}/pure_*)
- if test -z `fgrep -l '%pure-parser' $input`
+ if test -z `fgrep -i -l '%pure-parser' $input`
then
echo "%pure-parser" >>run_make.y
fi
@@ -106,7 +106,14 @@ then
sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y
- bison -Wno-other -Wno-conflicts-sr -Wconflicts-rr -y run_make.y
+ case $BISON in
+ [3-9].[0-9]*.[0-9]*)
+ bison -Wno-other -Wno-conflicts-sr -Wconflicts-rr -y -Wno-yacc run_make.y
+ ;;
+ *)
+ bison -y run_make.y
+ ;;
+ esac
if test -f "y.tab.c"
then
sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c
@@ -151,9 +158,10 @@ then
continue;
;;
*)
- if fgrep '%pure-parser' $input >/dev/null ||
- fgrep '%parse-param' $input >/dev/null ||
- fgrep '%lex-param' $input >/dev/null ||
+ if fgrep -i '%pure-parser' $input >/dev/null ||
+ fgrep -i '%parse-param' $input >/dev/null ||
+ fgrep -i '%lex-param' $input >/dev/null ||
+ fgrep -i '%token-table' $input >/dev/null ||
fgrep 'YYLEX_PARAM' $input >/dev/null
then
echo "... skipping $input"
diff --git a/test/run_test.sh b/test/run_test.sh
index 22ac61dc9ca9d..908a7d0f7a9a3 100755
--- a/test/run_test.sh
+++ b/test/run_test.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: run_test.sh,v 1.24 2014/07/15 19:21:10 tom Exp $
+# $Id: run_test.sh,v 1.31 2019/11/03 23:44:07 tom Exp $
# vi:ts=4 sw=4:
errors=0
@@ -17,6 +17,9 @@ test_diffs() {
else
sed -e s,$NEW,$REF, \
-e "s%$YACC_escaped%YACC%" \
+ -e "s%^yacc\>%YACC%" \
+ -e "s%YACC:.*option.*$%YACC: error message%" \
+ -e "s%^Usage: yacc\>%Usage: YACC%" \
-e '/YYPATCH/s/[0-9][0-9]*/"yyyymmdd"/' \
-e '/#define YYPATCH/s/PATCH/CHECK/' \
-e 's,#line \([1-9][0-9]*\) "'$REF_DIR'/,#line \1 ",' \
@@ -45,8 +48,7 @@ test_flags() {
root=$1
ROOT=test-$root
shift 1
- $YACC $* >$ROOT.output \
- 2>&1 >$ROOT.error
+ $YACC "$@" >$ROOT.output 2>$ROOT.error
for type in .output .error
do
NEW=$ROOT$type
@@ -55,6 +57,58 @@ test_flags() {
done
}
+test_stdin() {
+ echo "** testing stdin $*"
+ root=$1
+ ROOT=test-$root
+ shift 1
+ opts="$1"
+ shift 1
+ code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"`
+ if test "x$opts" = "x-"
+ then
+ $YACC -o $ROOT.$code $opts <$1 >$ROOT.output 2>$ROOT.error
+ else
+ $YACC -o $ROOT.$code $opts $1 >$ROOT.output 2>$ROOT.error
+ fi
+ for type in .output .error .$code
+ do
+ NEW=$ROOT$type
+ REF=$REF_DIR/$root$type
+ test_diffs
+ done
+}
+
+test_defines() {
+ echo "** testing defines $*"
+ root=$1
+ ROOT=test-$root
+ shift 1
+ opts=
+ while test $# != 1
+ do
+ opts="$opts $1"
+ shift 1
+ done
+ head=`echo "$1"|sed -e 's/y$/h/' -e "s,${TEST_DIR}/,,"`
+ code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"`
+ $YACC $opts -H $ROOT.$head $1 >$ROOT.output 2>$ROOT.error
+ for name in prefix.tab.c y.tab.c
+ do
+ if test -f $name
+ then
+ mv $name $ROOT.$code
+ break
+ fi
+ done
+ for name in .output .error .$head .$code
+ do
+ NEW=$ROOT$name
+ REF=$REF_DIR/$root$name
+ test_diffs
+ done
+}
+
if test $# = 1
then
PROG_DIR=`pwd`
@@ -138,6 +192,14 @@ rm -f $MYFILE.code.c
rm -f $MYFILE.*
+# Test special cases
+test_stdin stdin1 - ${TEST_DIR}/calc.y
+test_stdin stdin2 -- ${TEST_DIR}/calc.y
+
+test_defines defines1 ${TEST_DIR}/calc.y
+test_defines defines2 -d ${TEST_DIR}/calc.y
+test_defines defines3 -b prefix ${TEST_DIR}/calc.y
+
for input in ${TEST_DIR}/*.y
do
case $input in
diff --git a/test/yacc/big_b.error b/test/yacc/big_b.error
index e69de29bb2d1d..7019fded376df 100644
--- a/test/yacc/big_b.error
+++ b/test/yacc/big_b.error
@@ -0,0 +1,20 @@
+YACC: w - -B flag unsupported, reconfigure with --enable-btyacc
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/yacc/big_b.output b/test/yacc/big_b.output
index c98de14b4ad00..e69de29bb2d1d 100644
--- a/test/yacc/big_b.output
+++ b/test/yacc/big_b.output
@@ -1,19 +0,0 @@
-YACC: w - -B flag unsupported, reconfigure with --enable-btyacc
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/yacc/big_l.error b/test/yacc/big_l.error
index e69de29bb2d1d..be9f02a84acbb 100644
--- a/test/yacc/big_l.error
+++ b/test/yacc/big_l.error
@@ -0,0 +1,20 @@
+YACC: w - -L flag unsupported, reconfigure with --enable-btyacc
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/yacc/big_l.output b/test/yacc/big_l.output
index a39dc34b2d5a2..e69de29bb2d1d 100644
--- a/test/yacc/big_l.output
+++ b/test/yacc/big_l.output
@@ -1,19 +0,0 @@
-YACC: w - -L flag unsupported, reconfigure with --enable-btyacc
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/yacc/calc.tab.c b/test/yacc/calc.tab.c
index 6ce2cd43b1f7f..817bd006f8c6f 100644
--- a/test/yacc/calc.tab.c
+++ b/test/yacc/calc.tab.c
@@ -275,13 +275,15 @@ static const char *const calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -350,7 +352,7 @@ yylex(void)
}
return( c );
}
-#line 354 "calc.tab.c"
+#line 356 "calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -609,7 +611,7 @@ case 18:
#line 63 "calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 613 "calc.tab.c"
+#line 615 "calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/calc1.tab.c b/test/yacc/calc1.tab.c
index 0da4fde2944cd..eda1d00cc3300 100644
--- a/test/yacc/calc1.tab.c
+++ b/test/yacc/calc1.tab.c
@@ -323,13 +323,15 @@ static const char *const calc1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -487,7 +489,7 @@ vdiv(double a, double b, INTERVAL v)
{
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
}
-#line 491 "calc1.tab.c"
+#line 493 "calc1.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -849,7 +851,7 @@ case 28:
yyval.vval = yystack.l_mark[-1].vval;
}
break;
-#line 853 "calc1.tab.c"
+#line 855 "calc1.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/calc2.tab.c b/test/yacc/calc2.tab.c
index 8c82aa830cc6e..e2ab6f00dc641 100644
--- a/test/yacc/calc2.tab.c
+++ b/test/yacc/calc2.tab.c
@@ -277,13 +277,15 @@ static const char *const calc2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -363,7 +365,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 367 "calc2.tab.c"
+#line 369 "calc2.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -622,7 +624,7 @@ case 18:
#line 70 "calc2.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 626 "calc2.tab.c"
+#line 628 "calc2.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/calc3.tab.c b/test/yacc/calc3.tab.c
index 0869f325bd979..bfabb4acaa507 100644
--- a/test/yacc/calc3.tab.c
+++ b/test/yacc/calc3.tab.c
@@ -282,8 +282,9 @@ static const char *const calc3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -361,7 +362,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 365 "calc3.tab.c"
+#line 366 "calc3.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -428,6 +429,7 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
/* variables for the parser stack */
YYSTACKDATA yystack;
@@ -630,7 +632,7 @@ case 18:
#line 73 "calc3.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 634 "calc3.tab.c"
+#line 636 "calc3.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/calc_code_all.error b/test/yacc/calc_code_all.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/calc_code_all.error
diff --git a/test/yacc/calc_code_all.output b/test/yacc/calc_code_all.output
new file mode 100644
index 0000000000000..3aed47511c934
--- /dev/null
+++ b/test/yacc/calc_code_all.output
@@ -0,0 +1,461 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/yacc/calc_code_all.tab.c b/test/yacc/calc_code_all.tab.c
new file mode 100644
index 0000000000000..c17272f11e27d
--- /dev/null
+++ b/test/yacc/calc_code_all.tab.c
@@ -0,0 +1,699 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+/* %code "top" block start */
+#line 5 "calc_code_all.y"
+/* CODE-TOP */
+/* %code "top" block end */
+#line 22 "calc_code_all.tab.c"
+
+#ifndef yyparse
+#define yyparse calc_code_all_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_all_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_all_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_all_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_all_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_all_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_all_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_all_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_all_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_all_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_all_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_all_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_code_all_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_all_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_all_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_all_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_all_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_all_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_all_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_all_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_code_all_"
+
+#define YYPURE 0
+
+#line 9 "calc_code_all.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 117 "calc_code_all.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_all_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_all_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_all_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT calc_code_all_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_all_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_all_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT calc_code_all_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_all_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_all_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_all_name[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const calc_code_all_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* %code "requires" block start */
+#line 3 "calc_code_all.y"
+/* CODE-REQUIRES */
+/* %code "requires" block end */
+#line 299 "calc_code_all.tab.c"
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+
+/* %code "provides" block start */
+#line 4 "calc_code_all.y"
+/* CODE-PROVIDES */
+#line 6 "calc_code_all.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
+#line 333 "calc_code_all.tab.c"
+
+/* %code "" block start */
+#line 1 "calc_code_all.y"
+/* CODE-DEFAULT2 */
+#line 2 "calc_code_all.y"
+/* CODE-DEFAULT */
+/* %code "" block end */
+#line 341 "calc_code_all.tab.c"
+#line 73 "calc_code_all.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 384 "calc_code_all.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 35 "calc_code_all.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "calc_code_all.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "calc_code_all.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "calc_code_all.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "calc_code_all.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "calc_code_all.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "calc_code_all.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "calc_code_all.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "calc_code_all.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 643 "calc_code_all.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/calc_code_all.tab.h b/test/yacc/calc_code_all.tab.h
new file mode 100644
index 0000000000000..7edd87c3e6c47
--- /dev/null
+++ b/test/yacc/calc_code_all.tab.h
@@ -0,0 +1,13 @@
+/* %code "requires" block start */
+#line 3 "calc_code_all.y"
+/* CODE-REQUIRES */
+/* %code "requires" block end */
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+/* %code "provides" block start */
+#line 4 "calc_code_all.y"
+/* CODE-PROVIDES */
+#line 6 "calc_code_all.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
diff --git a/test/yacc/calc_code_default.error b/test/yacc/calc_code_default.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/calc_code_default.error
diff --git a/test/yacc/calc_code_default.output b/test/yacc/calc_code_default.output
new file mode 100644
index 0000000000000..3aed47511c934
--- /dev/null
+++ b/test/yacc/calc_code_default.output
@@ -0,0 +1,461 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/yacc/calc_code_default.tab.c b/test/yacc/calc_code_default.tab.c
new file mode 100644
index 0000000000000..275c0da8afe68
--- /dev/null
+++ b/test/yacc/calc_code_default.tab.c
@@ -0,0 +1,679 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+#ifndef yyparse
+#define yyparse calc_code_default_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_default_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_default_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_default_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_default_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_default_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_default_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_default_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_default_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_default_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_default_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_default_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_code_default_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_default_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_default_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_default_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_default_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_default_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_default_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_default_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_code_default_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_default.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 111 "calc_code_default.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_default_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_default_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_default_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT calc_code_default_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_default_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_default_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT calc_code_default_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_default_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_default_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_default_name[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const calc_code_default_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+
+/* %code "" block start */
+#line 1 "calc_code_default.y"
+/* CODE-DEFAULT */
+#line 2 "calc_code_default.y"
+/* CODE-DEFAULT2 */
+/* %code "" block end */
+#line 321 "calc_code_default.tab.c"
+#line 69 "calc_code_default.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 364 "calc_code_default.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_default.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_default.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_default.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_default.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_default.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_default.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_default.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_default.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_default.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 623 "calc_code_default.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/calc_code_default.tab.h b/test/yacc/calc_code_default.tab.h
new file mode 100644
index 0000000000000..19211182d6b3a
--- /dev/null
+++ b/test/yacc/calc_code_default.tab.h
@@ -0,0 +1,3 @@
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
diff --git a/test/yacc/calc_code_imports.error b/test/yacc/calc_code_imports.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/calc_code_imports.error
diff --git a/test/yacc/calc_code_imports.output b/test/yacc/calc_code_imports.output
new file mode 100644
index 0000000000000..3aed47511c934
--- /dev/null
+++ b/test/yacc/calc_code_imports.output
@@ -0,0 +1,461 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/yacc/calc_code_imports.tab.c b/test/yacc/calc_code_imports.tab.c
new file mode 100644
index 0000000000000..1ef6ad019c178
--- /dev/null
+++ b/test/yacc/calc_code_imports.tab.c
@@ -0,0 +1,671 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+#ifndef yyparse
+#define yyparse calc_code_imports_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_imports_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_imports_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_imports_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_imports_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_imports_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_imports_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_imports_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_imports_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_imports_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_imports_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_imports_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_code_imports_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_imports_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_imports_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_imports_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_imports_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_imports_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_imports_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_imports_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_code_imports_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_imports.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 111 "calc_code_imports.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_imports_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_imports_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_imports_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT calc_code_imports_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_imports_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_imports_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT calc_code_imports_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_imports_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_imports_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_imports_name[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const calc_code_imports_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 69 "calc_code_imports.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 356 "calc_code_imports.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_imports.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_imports.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_imports.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_imports.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_imports.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_imports.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_imports.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_imports.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 615 "calc_code_imports.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/calc_code_imports.tab.h b/test/yacc/calc_code_imports.tab.h
new file mode 100644
index 0000000000000..19211182d6b3a
--- /dev/null
+++ b/test/yacc/calc_code_imports.tab.h
@@ -0,0 +1,3 @@
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
diff --git a/test/yacc/calc_code_provides.error b/test/yacc/calc_code_provides.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/calc_code_provides.error
diff --git a/test/yacc/calc_code_provides.output b/test/yacc/calc_code_provides.output
new file mode 100644
index 0000000000000..3aed47511c934
--- /dev/null
+++ b/test/yacc/calc_code_provides.output
@@ -0,0 +1,461 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/yacc/calc_code_provides.tab.c b/test/yacc/calc_code_provides.tab.c
new file mode 100644
index 0000000000000..3d2555f6260a8
--- /dev/null
+++ b/test/yacc/calc_code_provides.tab.c
@@ -0,0 +1,679 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+#ifndef yyparse
+#define yyparse calc_code_provides_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_provides_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_provides_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_provides_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_provides_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_provides_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_provides_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_provides_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_provides_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_provides_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_provides_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_provides_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_code_provides_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_provides_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_provides_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_provides_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_provides_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_provides_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_provides_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_provides_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_code_provides_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_provides.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 111 "calc_code_provides.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_provides_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_provides_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_provides_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT calc_code_provides_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_provides_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_provides_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT calc_code_provides_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_provides_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_provides_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_provides_name[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const calc_code_provides_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+
+/* %code "provides" block start */
+#line 1 "calc_code_provides.y"
+/* CODE-PROVIDES */
+#line 2 "calc_code_provides.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
+#line 321 "calc_code_provides.tab.c"
+#line 69 "calc_code_provides.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 364 "calc_code_provides.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_provides.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_provides.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_provides.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_provides.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_provides.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_provides.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_provides.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_provides.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 623 "calc_code_provides.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/calc_code_provides.tab.h b/test/yacc/calc_code_provides.tab.h
new file mode 100644
index 0000000000000..a7004790d1f47
--- /dev/null
+++ b/test/yacc/calc_code_provides.tab.h
@@ -0,0 +1,9 @@
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+/* %code "provides" block start */
+#line 1 "calc_code_provides.y"
+/* CODE-PROVIDES */
+#line 2 "calc_code_provides.y"
+/* CODE-PROVIDES2 */
+/* %code "provides" block end */
diff --git a/test/yacc/calc_code_requires.error b/test/yacc/calc_code_requires.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/calc_code_requires.error
diff --git a/test/yacc/calc_code_requires.output b/test/yacc/calc_code_requires.output
new file mode 100644
index 0000000000000..3aed47511c934
--- /dev/null
+++ b/test/yacc/calc_code_requires.output
@@ -0,0 +1,461 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/yacc/calc_code_requires.tab.c b/test/yacc/calc_code_requires.tab.c
new file mode 100644
index 0000000000000..50eb05cb304b0
--- /dev/null
+++ b/test/yacc/calc_code_requires.tab.c
@@ -0,0 +1,679 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+#ifndef yyparse
+#define yyparse calc_code_requires_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_requires_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_requires_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_requires_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_requires_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_requires_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_requires_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_requires_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_requires_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_requires_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_requires_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_requires_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_code_requires_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_requires_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_requires_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_requires_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_requires_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_requires_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_requires_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_requires_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_code_requires_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_requires.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 111 "calc_code_requires.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_requires_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_requires_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_requires_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT calc_code_requires_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_requires_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_requires_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT calc_code_requires_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_requires_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_requires_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_requires_name[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const calc_code_requires_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* %code "requires" block start */
+#line 1 "calc_code_requires.y"
+/* CODE-REQUIRES */
+#line 2 "calc_code_requires.y"
+/* CODE-REQUIRES2 */
+/* %code "requires" block end */
+#line 295 "calc_code_requires.tab.c"
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 69 "calc_code_requires.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 364 "calc_code_requires.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_requires.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_requires.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_requires.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_requires.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_requires.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_requires.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_requires.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_requires.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 623 "calc_code_requires.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/calc_code_requires.tab.h b/test/yacc/calc_code_requires.tab.h
new file mode 100644
index 0000000000000..b734c8358f5a6
--- /dev/null
+++ b/test/yacc/calc_code_requires.tab.h
@@ -0,0 +1,9 @@
+/* %code "requires" block start */
+#line 1 "calc_code_requires.y"
+/* CODE-REQUIRES */
+#line 2 "calc_code_requires.y"
+/* CODE-REQUIRES2 */
+/* %code "requires" block end */
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
diff --git a/test/yacc/calc_code_top.error b/test/yacc/calc_code_top.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/calc_code_top.error
diff --git a/test/yacc/calc_code_top.output b/test/yacc/calc_code_top.output
new file mode 100644
index 0000000000000..3aed47511c934
--- /dev/null
+++ b/test/yacc/calc_code_top.output
@@ -0,0 +1,461 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/yacc/calc_code_top.tab.c b/test/yacc/calc_code_top.tab.c
new file mode 100644
index 0000000000000..c5e4e3fb351ff
--- /dev/null
+++ b/test/yacc/calc_code_top.tab.c
@@ -0,0 +1,679 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+
+/* %code "top" block start */
+#line 1 "calc_code_top.y"
+/* CODE-TOP */
+#line 2 "calc_code_top.y"
+/* CODE-TOP2 */
+/* %code "top" block end */
+#line 24 "calc_code_top.tab.c"
+
+#ifndef yyparse
+#define yyparse calc_code_top_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_code_top_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_code_top_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_code_top_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_code_top_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_code_top_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_code_top_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_code_top_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_code_top_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_code_top_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_code_top_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_code_top_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_code_top_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_code_top_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_code_top_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_code_top_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_code_top_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_code_top_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_code_top_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_code_top_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_code_top_"
+
+#define YYPURE 0
+
+#line 5 "calc_code_top.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 119 "calc_code_top.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT calc_code_top_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT calc_code_top_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT calc_code_top_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT calc_code_top_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT calc_code_top_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT calc_code_top_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT calc_code_top_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT calc_code_top_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT calc_code_top_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const calc_code_top_name[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const calc_code_top_rule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 69 "calc_code_top.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 364 "calc_code_top.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 31 "calc_code_top.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 35 "calc_code_top.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 37 "calc_code_top.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 41 "calc_code_top.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 43 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 45 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 47 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 49 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 51 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 53 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 55 "calc_code_top.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 57 "calc_code_top.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 59 "calc_code_top.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 64 "calc_code_top.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 66 "calc_code_top.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 623 "calc_code_top.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/calc_code_top.tab.h b/test/yacc/calc_code_top.tab.h
new file mode 100644
index 0000000000000..19211182d6b3a
--- /dev/null
+++ b/test/yacc/calc_code_top.tab.h
@@ -0,0 +1,3 @@
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
diff --git a/test/yacc/code_calc.code.c b/test/yacc/code_calc.code.c
index 2c04715f57b5b..a1d4f4b6c50ee 100644
--- a/test/yacc/code_calc.code.c
+++ b/test/yacc/code_calc.code.c
@@ -180,13 +180,15 @@ extern char *yyname[];
extern char *yyrule[];
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -259,7 +261,7 @@ yylex(void)
}
return( c );
}
-#line 263 "code_calc.code.c"
+#line 265 "code_calc.code.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -518,7 +520,7 @@ case 18:
#line 67 "code_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 522 "code_calc.code.c"
+#line 524 "code_calc.code.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/code_error.code.c b/test/yacc/code_error.code.c
index a22464c403f21..b117ce6d21cd2 100644
--- a/test/yacc/code_error.code.c
+++ b/test/yacc/code_error.code.c
@@ -170,13 +170,15 @@ extern char *yyname[];
extern char *yyrule[];
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -229,7 +231,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 233 "code_error.code.c"
+#line 235 "code_error.code.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/yacc/defines1.calc.c b/test/yacc/defines1.calc.c
new file mode 100644
index 0000000000000..f7ee6749fe49b
--- /dev/null
+++ b/test/yacc/defines1.calc.c
@@ -0,0 +1,595 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 31 "y.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 280 "y.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 539 "y.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/defines1.calc.h b/test/yacc/defines1.calc.h
new file mode 100644
index 0000000000000..19211182d6b3a
--- /dev/null
+++ b/test/yacc/defines1.calc.h
@@ -0,0 +1,3 @@
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
diff --git a/test/yacc/defines1.error b/test/yacc/defines1.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/defines1.error
diff --git a/test/yacc/defines1.output b/test/yacc/defines1.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/defines1.output
diff --git a/test/yacc/defines2.calc.c b/test/yacc/defines2.calc.c
new file mode 100644
index 0000000000000..f7ee6749fe49b
--- /dev/null
+++ b/test/yacc/defines2.calc.c
@@ -0,0 +1,595 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 31 "y.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 280 "y.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 539 "y.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/defines2.calc.h b/test/yacc/defines2.calc.h
new file mode 100644
index 0000000000000..19211182d6b3a
--- /dev/null
+++ b/test/yacc/defines2.calc.h
@@ -0,0 +1,3 @@
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
diff --git a/test/yacc/defines2.error b/test/yacc/defines2.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/defines2.error
diff --git a/test/yacc/defines2.output b/test/yacc/defines2.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/defines2.output
diff --git a/test/yacc/defines3.calc.c b/test/yacc/defines3.calc.c
new file mode 100644
index 0000000000000..538726bb1f431
--- /dev/null
+++ b/test/yacc/defines3.calc.c
@@ -0,0 +1,595 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 31 "prefix.tab.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 280 "prefix.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 539 "prefix.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/defines3.calc.h b/test/yacc/defines3.calc.h
new file mode 100644
index 0000000000000..19211182d6b3a
--- /dev/null
+++ b/test/yacc/defines3.calc.h
@@ -0,0 +1,3 @@
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
diff --git a/test/yacc/defines3.error b/test/yacc/defines3.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/defines3.error
diff --git a/test/yacc/defines3.output b/test/yacc/defines3.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/defines3.output
diff --git a/test/yacc/empty.tab.c b/test/yacc/empty.tab.c
index 465a0a3cd157b..e338655319578 100644
--- a/test/yacc/empty.tab.c
+++ b/test/yacc/empty.tab.c
@@ -194,13 +194,15 @@ static const char *const empty_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -240,7 +242,7 @@ static void
YYERROR_DECL() {
printf("%s\n",s);
}
-#line 244 "empty.tab.c"
+#line 246 "empty.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/yacc/err_syntax10.tab.c b/test/yacc/err_syntax10.tab.c
index bbfe2e6528907..e4b15781e448b 100644
--- a/test/yacc/err_syntax10.tab.c
+++ b/test/yacc/err_syntax10.tab.c
@@ -184,13 +184,15 @@ static const char *const err_syntax10_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -239,7 +241,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 243 "err_syntax10.tab.c"
+#line 245 "err_syntax10.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/yacc/err_syntax11.tab.c b/test/yacc/err_syntax11.tab.c
index 4da7c62ac9e09..070661ed5dbc9 100644
--- a/test/yacc/err_syntax11.tab.c
+++ b/test/yacc/err_syntax11.tab.c
@@ -190,13 +190,15 @@ static const char *const err_syntax11_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -245,7 +247,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 249 "err_syntax11.tab.c"
+#line 251 "err_syntax11.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/yacc/err_syntax12.tab.c b/test/yacc/err_syntax12.tab.c
index af33ee2be1b57..7c6c63e9494f8 100644
--- a/test/yacc/err_syntax12.tab.c
+++ b/test/yacc/err_syntax12.tab.c
@@ -196,13 +196,15 @@ static const char *const err_syntax12_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -251,7 +253,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 255 "err_syntax12.tab.c"
+#line 257 "err_syntax12.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/yacc/err_syntax18.tab.c b/test/yacc/err_syntax18.tab.c
index 15f7a7a083a20..6038c1436ba65 100644
--- a/test/yacc/err_syntax18.tab.c
+++ b/test/yacc/err_syntax18.tab.c
@@ -192,13 +192,15 @@ static const char *const err_syntax18_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -247,7 +249,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 251 "err_syntax18.tab.c"
+#line 253 "err_syntax18.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -450,7 +452,7 @@ case 1:
#line 9 "err_syntax18.y"
{ yyval = yystack.l_mark[1]; }
break;
-#line 454 "err_syntax18.tab.c"
+#line 456 "err_syntax18.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/err_syntax20.tab.c b/test/yacc/err_syntax20.tab.c
index 526addee8c697..ea9fc87ce3a55 100644
--- a/test/yacc/err_syntax20.tab.c
+++ b/test/yacc/err_syntax20.tab.c
@@ -188,13 +188,15 @@ static const char *const err_syntax20_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -243,7 +245,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 247 "err_syntax20.tab.c"
+#line 249 "err_syntax20.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -446,7 +448,7 @@ case 1:
#line 12 "err_syntax20.y"
{ yystack.l_mark[-1].rechk = 3; }
break;
-#line 450 "err_syntax20.tab.c"
+#line 452 "err_syntax20.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/error.tab.c b/test/yacc/error.tab.c
index 47a39d8c13138..93d901149cae2 100644
--- a/test/yacc/error.tab.c
+++ b/test/yacc/error.tab.c
@@ -190,13 +190,15 @@ static const char *const error_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -245,7 +247,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 249 "error.tab.c"
+#line 251 "error.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/yacc/expr.oxout.tab.c b/test/yacc/expr.oxout.tab.c
index b4b7ec41bd0cf..0edef3ae96598 100644
--- a/test/yacc/expr.oxout.tab.c
+++ b/test/yacc/expr.oxout.tab.c
@@ -287,13 +287,15 @@ static const char *const expr.oxout_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -1641,7 +1643,7 @@ void yyyUnsolvedInstSearchTrav(yyyGNT *pNode)
-#line 1645 "expr.oxout.tab.c"
+#line 1647 "expr.oxout.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -1898,7 +1900,7 @@ case 10:
yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);
yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}}
break;
-#line 1902 "expr.oxout.tab.c"
+#line 1904 "expr.oxout.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/grammar.tab.c b/test/yacc/grammar.tab.c
index c4aee12618f2e..399e0f8c74e7c 100644
--- a/test/yacc/grammar.tab.c
+++ b/test/yacc/grammar.tab.c
@@ -124,6 +124,7 @@ static void yyerror(const char *s);
/* #include "cproto.h" */
#define MAX_TEXT_SIZE 1024
+#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3)
/* Prototype styles */
#if OPT_LINTLIBRARY
@@ -384,7 +385,7 @@ haveAnsiParam (void)
}
return FALSE;
}
-#line 388 "grammar.tab.c"
+#line 389 "grammar.tab.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@@ -884,13 +885,15 @@ static const char *const grammar_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -917,7 +920,7 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 1014 "grammar.y"
+#line 1015 "grammar.y"
/* lex.yy.c */
#define BEGIN yy_start = 1 + 2 *
@@ -934,7 +937,7 @@ extern char *yytext;
extern FILE *yyin, *yyout;
static int curly; /* number of curly brace nesting levels */
-static int ly_count; /* number of occurances of %% */
+static int ly_count; /* number of occurrences of %% */
static int inc_depth; /* include nesting level */
static SymbolTable *included_files; /* files already included */
static int yy_start = 0; /* start state number */
@@ -1088,7 +1091,7 @@ free_parser(void)
#endif
}
#endif
-#line 1092 "grammar.tab.c"
+#line 1095 "grammar.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -1288,19 +1291,19 @@ yyreduce:
switch (yyn)
{
case 10:
-#line 377 "grammar.y"
+#line 378 "grammar.y"
{
yyerrok;
}
break;
case 11:
-#line 381 "grammar.y"
+#line 382 "grammar.y"
{
yyerrok;
}
break;
case 13:
-#line 392 "grammar.y"
+#line 393 "grammar.y"
{
/* Provide an empty action here so bison will not complain about
* incompatible types in the default action it normally would
@@ -1309,13 +1312,13 @@ case 13:
}
break;
case 14:
-#line 399 "grammar.y"
+#line 400 "grammar.y"
{
/* empty */
}
break;
case 15:
-#line 406 "grammar.y"
+#line 407 "grammar.y"
{
#if OPT_LINTLIBRARY
if (types_out && want_typedef()) {
@@ -1328,7 +1331,7 @@ case 15:
}
break;
case 16:
-#line 417 "grammar.y"
+#line 418 "grammar.y"
{
if (func_params != NULL) {
set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
@@ -1344,32 +1347,32 @@ case 16:
}
break;
case 17:
-#line 431 "grammar.y"
+#line 432 "grammar.y"
{
cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
free_decl_spec(&yystack.l_mark[0].decl_spec);
}
break;
case 18:
-#line 436 "grammar.y"
+#line 437 "grammar.y"
{
end_typedef();
}
break;
case 19:
-#line 443 "grammar.y"
+#line 444 "grammar.y"
{
begin_typedef();
}
break;
case 20:
-#line 447 "grammar.y"
+#line 448 "grammar.y"
{
begin_typedef();
}
break;
case 23:
-#line 459 "grammar.y"
+#line 460 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -1383,7 +1386,7 @@ case 23:
}
break;
case 24:
-#line 471 "grammar.y"
+#line 472 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -1394,7 +1397,7 @@ case 24:
}
break;
case 25:
-#line 483 "grammar.y"
+#line 484 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
@@ -1407,7 +1410,7 @@ case 25:
}
break;
case 26:
-#line 494 "grammar.y"
+#line 495 "grammar.y"
{
/* If we're converting to K&R and we've got a nominally K&R
* function which has a parameter which is ANSI (i.e., a prototyped
@@ -1433,7 +1436,7 @@ case 26:
}
break;
case 28:
-#line 519 "grammar.y"
+#line 520 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
yyerror("syntax error");
@@ -1445,7 +1448,7 @@ case 28:
}
break;
case 29:
-#line 529 "grammar.y"
+#line 530 "grammar.y"
{
DeclSpec decl_spec;
@@ -1463,7 +1466,7 @@ case 29:
}
break;
case 36:
-#line 560 "grammar.y"
+#line 561 "grammar.y"
{
join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
free(yystack.l_mark[-1].decl_spec.text);
@@ -1471,115 +1474,115 @@ case 36:
}
break;
case 40:
-#line 575 "grammar.y"
+#line 576 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 41:
-#line 579 "grammar.y"
+#line 580 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
}
break;
case 42:
-#line 583 "grammar.y"
+#line 584 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 43:
-#line 587 "grammar.y"
+#line 588 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
}
break;
case 44:
-#line 591 "grammar.y"
+#line 592 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
}
break;
case 45:
-#line 595 "grammar.y"
+#line 596 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
}
break;
case 46:
-#line 602 "grammar.y"
+#line 603 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 47:
-#line 606 "grammar.y"
+#line 607 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 48:
-#line 610 "grammar.y"
+#line 611 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
}
break;
case 49:
-#line 614 "grammar.y"
+#line 615 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 50:
-#line 618 "grammar.y"
+#line 619 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 51:
-#line 622 "grammar.y"
+#line 623 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
}
break;
case 52:
-#line 626 "grammar.y"
+#line 627 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 53:
-#line 630 "grammar.y"
+#line 631 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 54:
-#line 634 "grammar.y"
+#line 635 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 55:
-#line 638 "grammar.y"
+#line 639 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 56:
-#line 642 "grammar.y"
+#line 643 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 57:
-#line 646 "grammar.y"
+#line 647 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 58:
-#line 650 "grammar.y"
+#line 651 "grammar.y"
{
Symbol *s;
s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
@@ -1588,13 +1591,13 @@ case 58:
}
break;
case 61:
-#line 662 "grammar.y"
+#line 663 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 62:
-#line 666 "grammar.y"
+#line 667 "grammar.y"
{
/* This rule allows the <pointer> nonterminal to scan #define
* names as if they were type modifiers.
@@ -1606,56 +1609,56 @@ case 62:
}
break;
case 63:
-#line 679 "grammar.y"
+#line 680 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
}
break;
case 64:
-#line 686 "grammar.y"
+#line 687 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 65:
-#line 693 "grammar.y"
+#line 694 "grammar.y"
{
- (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 66:
-#line 701 "grammar.y"
+#line 702 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 67:
-#line 705 "grammar.y"
+#line 706 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 68:
-#line 712 "grammar.y"
+#line 713 "grammar.y"
{
new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
}
break;
case 69:
-#line 716 "grammar.y"
+#line 717 "grammar.y"
{
add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
}
break;
case 70:
-#line 723 "grammar.y"
+#line 724 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -1666,7 +1669,7 @@ case 70:
}
break;
case 71:
-#line 732 "grammar.y"
+#line 733 "grammar.y"
{
if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -1676,42 +1679,42 @@ case 71:
}
break;
case 73:
-#line 744 "grammar.y"
+#line 745 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
}
break;
case 74:
-#line 751 "grammar.y"
+#line 752 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
- (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
+ (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text);
new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 75:
-#line 758 "grammar.y"
+#line 759 "grammar.y"
{
- (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 76:
-#line 766 "grammar.y"
+#line 767 "grammar.y"
{
imply_typedef("enum");
yyval.text = yystack.l_mark[0].text;
}
break;
case 79:
-#line 779 "grammar.y"
+#line 780 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
- (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-1].text.begin;
@@ -1719,32 +1722,32 @@ case 79:
}
break;
case 81:
-#line 792 "grammar.y"
+#line 793 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
}
break;
case 82:
-#line 796 "grammar.y"
+#line 797 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "(%s)", yyval.declarator->text);
+ (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-2].text.begin;
}
break;
case 83:
-#line 804 "grammar.y"
+#line 805 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
}
break;
case 84:
-#line 811 "grammar.y"
+#line 812 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1754,7 +1757,7 @@ case 84:
}
break;
case 85:
-#line 819 "grammar.y"
+#line 820 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1764,28 +1767,28 @@ case 85:
}
break;
case 86:
-#line 830 "grammar.y"
+#line 831 "grammar.y"
{
- (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
+ (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
}
break;
case 87:
-#line 835 "grammar.y"
+#line 836 "grammar.y"
{
- (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
+ (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-2].text.begin;
}
break;
case 88:
-#line 843 "grammar.y"
+#line 844 "grammar.y"
{
strcpy(yyval.text.text, "");
yyval.text.begin = 0L;
}
break;
case 90:
-#line 852 "grammar.y"
+#line 853 "grammar.y"
{
(void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
@@ -1793,132 +1796,132 @@ case 90:
}
break;
case 91:
-#line 858 "grammar.y"
+#line 859 "grammar.y"
{
- (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
+ (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
free(yystack.l_mark[0].decl_spec.text);
}
break;
case 93:
-#line 868 "grammar.y"
+#line 869 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
}
break;
case 94:
-#line 875 "grammar.y"
+#line 876 "grammar.y"
{
new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
}
break;
case 95:
-#line 879 "grammar.y"
+#line 880 "grammar.y"
{
add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
}
break;
case 96:
-#line 886 "grammar.y"
+#line 887 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 97:
-#line 891 "grammar.y"
+#line 892 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 98:
-#line 896 "grammar.y"
+#line 897 "grammar.y"
{
check_untagged(&yystack.l_mark[0].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
}
break;
case 99:
-#line 904 "grammar.y"
+#line 905 "grammar.y"
{
new_ident_list(&yyval.param_list);
}
break;
case 101:
-#line 912 "grammar.y"
+#line 913 "grammar.y"
{
new_ident_list(&yyval.param_list);
add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
}
break;
case 102:
-#line 917 "grammar.y"
+#line 918 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
}
break;
case 103:
-#line 924 "grammar.y"
+#line 925 "grammar.y"
{
yyval.text = yystack.l_mark[0].text;
}
break;
case 104:
-#line 928 "grammar.y"
+#line 929 "grammar.y"
{
#if OPT_LINTLIBRARY
if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
yyval.text = yystack.l_mark[0].text;
} else
#endif
- (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text);
+ (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
}
break;
case 105:
-#line 941 "grammar.y"
+#line 942 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 106:
-#line 945 "grammar.y"
+#line 946 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
- (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-1].text.begin;
}
break;
case 108:
-#line 957 "grammar.y"
+#line 958 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "(%s)", yyval.declarator->text);
+ (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
yyval.declarator->begin = yystack.l_mark[-2].text.begin;
}
break;
case 109:
-#line 965 "grammar.y"
+#line 966 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
- (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
+ (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text);
free(yyval.declarator->text);
yyval.declarator->text = xstrdup(buf);
}
break;
case 110:
-#line 972 "grammar.y"
+#line 973 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 111:
-#line 976 "grammar.y"
+#line 977 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1928,7 +1931,7 @@ case 111:
}
break;
case 112:
-#line 984 "grammar.y"
+#line 985 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
@@ -1937,7 +1940,7 @@ case 112:
}
break;
case 113:
-#line 991 "grammar.y"
+#line 992 "grammar.y"
{
Declarator *d;
@@ -1950,7 +1953,7 @@ case 113:
}
break;
case 114:
-#line 1002 "grammar.y"
+#line 1003 "grammar.y"
{
Declarator *d;
@@ -1961,7 +1964,7 @@ case 114:
yyval.declarator->func_def = FUNC_ANSI;
}
break;
-#line 1965 "grammar.tab.c"
+#line 1968 "grammar.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/help.error b/test/yacc/help.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/yacc/help.error
+++ b/test/yacc/help.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/yacc/help.output b/test/yacc/help.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/yacc/help.output
+++ b/test/yacc/help.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/yacc/no_b_opt.error b/test/yacc/no_b_opt.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/yacc/no_b_opt.error
+++ b/test/yacc/no_b_opt.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/yacc/no_b_opt.output b/test/yacc/no_b_opt.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/yacc/no_b_opt.output
+++ b/test/yacc/no_b_opt.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/yacc/no_b_opt1.error b/test/yacc/no_b_opt1.error
index e69de29bb2d1d..87286c2661e6f 100644
--- a/test/yacc/no_b_opt1.error
+++ b/test/yacc/no_b_opt1.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.c"
diff --git a/test/yacc/no_b_opt1.output b/test/yacc/no_b_opt1.output
index 87286c2661e6f..e69de29bb2d1d 100644
--- a/test/yacc/no_b_opt1.output
+++ b/test/yacc/no_b_opt1.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.c"
diff --git a/test/yacc/no_code_c.error b/test/yacc/no_code_c.error
index e69de29bb2d1d..87286c2661e6f 100644
--- a/test/yacc/no_code_c.error
+++ b/test/yacc/no_code_c.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.c"
diff --git a/test/yacc/no_code_c.output b/test/yacc/no_code_c.output
index 87286c2661e6f..e69de29bb2d1d 100644
--- a/test/yacc/no_code_c.output
+++ b/test/yacc/no_code_c.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.c"
diff --git a/test/yacc/no_defines.error b/test/yacc/no_defines.error
index e69de29bb2d1d..773985d66f33c 100644
--- a/test/yacc/no_defines.error
+++ b/test/yacc/no_defines.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.h"
diff --git a/test/yacc/no_defines.output b/test/yacc/no_defines.output
index 773985d66f33c..e69de29bb2d1d 100644
--- a/test/yacc/no_defines.output
+++ b/test/yacc/no_defines.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.h"
diff --git a/test/yacc/no_graph.error b/test/yacc/no_graph.error
index e69de29bb2d1d..d5575f4004215 100644
--- a/test/yacc/no_graph.error
+++ b/test/yacc/no_graph.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.dot"
diff --git a/test/yacc/no_graph.output b/test/yacc/no_graph.output
index d5575f4004215..e69de29bb2d1d 100644
--- a/test/yacc/no_graph.output
+++ b/test/yacc/no_graph.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.dot"
diff --git a/test/yacc/no_include.error b/test/yacc/no_include.error
index e69de29bb2d1d..3ece4a454e392 100644
--- a/test/yacc/no_include.error
+++ b/test/yacc/no_include.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.i"
diff --git a/test/yacc/no_include.output b/test/yacc/no_include.output
index 3ece4a454e392..e69de29bb2d1d 100644
--- a/test/yacc/no_include.output
+++ b/test/yacc/no_include.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.i"
diff --git a/test/yacc/no_opts.error b/test/yacc/no_opts.error
index e69de29bb2d1d..ad3131a69ab68 100644
--- a/test/yacc/no_opts.error
+++ b/test/yacc/no_opts.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.y"
diff --git a/test/yacc/no_opts.output b/test/yacc/no_opts.output
index ad3131a69ab68..e69de29bb2d1d 100644
--- a/test/yacc/no_opts.output
+++ b/test/yacc/no_opts.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.y"
diff --git a/test/yacc/no_output.error b/test/yacc/no_output.error
index e69de29bb2d1d..a2f142a9d531a 100644
--- a/test/yacc/no_output.error
+++ b/test/yacc/no_output.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.output"
diff --git a/test/yacc/no_output.output b/test/yacc/no_output.output
index a2f142a9d531a..e69de29bb2d1d 100644
--- a/test/yacc/no_output.output
+++ b/test/yacc/no_output.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.output"
diff --git a/test/yacc/no_output1.error b/test/yacc/no_output1.error
index e69de29bb2d1d..a2f142a9d531a 100644
--- a/test/yacc/no_output1.error
+++ b/test/yacc/no_output1.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.output"
diff --git a/test/yacc/no_output1.output b/test/yacc/no_output1.output
index a2f142a9d531a..e69de29bb2d1d 100644
--- a/test/yacc/no_output1.output
+++ b/test/yacc/no_output1.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.output"
diff --git a/test/yacc/no_output2.error b/test/yacc/no_output2.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/yacc/no_output2.error
+++ b/test/yacc/no_output2.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/yacc/no_output2.output b/test/yacc/no_output2.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/yacc/no_output2.output
+++ b/test/yacc/no_output2.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/yacc/no_p_opt.error b/test/yacc/no_p_opt.error
index e69de29bb2d1d..f69a74a93091e 100644
--- a/test/yacc/no_p_opt.error
+++ b/test/yacc/no_p_opt.error
@@ -0,0 +1,20 @@
+YACC: error message
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/yacc/no_p_opt.output b/test/yacc/no_p_opt.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/yacc/no_p_opt.output
+++ b/test/yacc/no_p_opt.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/yacc/no_p_opt1.error b/test/yacc/no_p_opt1.error
index e69de29bb2d1d..87286c2661e6f 100644
--- a/test/yacc/no_p_opt1.error
+++ b/test/yacc/no_p_opt1.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.c"
diff --git a/test/yacc/no_p_opt1.output b/test/yacc/no_p_opt1.output
index 87286c2661e6f..e69de29bb2d1d 100644
--- a/test/yacc/no_p_opt1.output
+++ b/test/yacc/no_p_opt1.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.c"
diff --git a/test/yacc/no_verbose.error b/test/yacc/no_verbose.error
index e69de29bb2d1d..a2f142a9d531a 100644
--- a/test/yacc/no_verbose.error
+++ b/test/yacc/no_verbose.error
@@ -0,0 +1 @@
+YACC: f - cannot open "nosuchfile.output"
diff --git a/test/yacc/no_verbose.output b/test/yacc/no_verbose.output
index a2f142a9d531a..e69de29bb2d1d 100644
--- a/test/yacc/no_verbose.output
+++ b/test/yacc/no_verbose.output
@@ -1 +0,0 @@
-YACC: f - cannot open "nosuchfile.output"
diff --git a/test/yacc/nostdin.error b/test/yacc/nostdin.error
index e69de29bb2d1d..67101620d2c1e 100644
--- a/test/yacc/nostdin.error
+++ b/test/yacc/nostdin.error
@@ -0,0 +1,19 @@
+Usage: YACC [options] filename
+
+Options:
+ -b file_prefix set filename prefix (default "y.")
+ -B create a backtracking parser
+ -d write definitions (.tab.h)
+ -H defines_file write definitions to defines_file
+ -i write interface (y.tab.i)
+ -g write a graphical description
+ -l suppress #line directives
+ -L enable position processing, e.g., "%locations"
+ -o output_file (default ".tab.c")
+ -p symbol_prefix set symbol prefix (default "yy")
+ -P create a reentrant parser, e.g., "%pure-parser"
+ -r produce separate code and table files (y.code.c)
+ -s suppress #define's for quoted names in %token lines
+ -t add debugging support
+ -v write description (y.output)
+ -V show version information and exit
diff --git a/test/yacc/nostdin.output b/test/yacc/nostdin.output
index 112b7c7a41c56..e69de29bb2d1d 100644
--- a/test/yacc/nostdin.output
+++ b/test/yacc/nostdin.output
@@ -1,18 +0,0 @@
-Usage: YACC [options] filename
-
-Options:
- -b file_prefix set filename prefix (default "y.")
- -B create a backtracking parser
- -d write definitions (.tab.h)
- -i write interface (y.tab.i)
- -g write a graphical description
- -l suppress #line directives
- -L enable position processing, e.g., "%locations"
- -o output_file (default ".tab.c")
- -p symbol_prefix set symbol prefix (default "yy")
- -P create a reentrant parser, e.g., "%pure-parser"
- -r produce separate code and table files (y.code.c)
- -s suppress #define's for quoted names in %token lines
- -t add debugging support
- -v write description (y.output)
- -V show version information and exit
diff --git a/test/yacc/ok_syntax1.tab.c b/test/yacc/ok_syntax1.tab.c
index 0b1267e7a84c8..c1bbc4ffc48e6 100644
--- a/test/yacc/ok_syntax1.tab.c
+++ b/test/yacc/ok_syntax1.tab.c
@@ -306,8 +306,9 @@ static const char *const ok_syntax1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -385,7 +386,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 389 "ok_syntax1.tab.c"
+#line 390 "ok_syntax1.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -452,6 +453,7 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
/* variables for the parser stack */
YYSTACKDATA yystack;
@@ -654,7 +656,7 @@ case 18:
#line 101 "ok_syntax1.y"
{ yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; }
break;
-#line 658 "ok_syntax1.tab.c"
+#line 660 "ok_syntax1.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/ok_syntax1.tab.h b/test/yacc/ok_syntax1.tab.h
index 8a51fa00660e4..892b211c8a715 100644
--- a/test/yacc/ok_syntax1.tab.h
+++ b/test/yacc/ok_syntax1.tab.h
@@ -27,4 +27,3 @@ typedef union
double dval;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
-extern YYSTYPE ok_syntax1_lval;
diff --git a/test/yacc/pure_calc.tab.c b/test/yacc/pure_calc.tab.c
index 95afec1b3b13b..ee47ce6cb0212 100644
--- a/test/yacc/pure_calc.tab.c
+++ b/test/yacc/pure_calc.tab.c
@@ -285,8 +285,9 @@ static const char *const calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -357,7 +358,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 361 "pure_calc.tab.c"
+#line 362 "pure_calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -424,6 +425,7 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
/* variables for the parser stack */
YYSTACKDATA yystack;
@@ -626,7 +628,7 @@ case 18:
#line 69 "pure_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 630 "pure_calc.tab.c"
+#line 632 "pure_calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/pure_error.tab.c b/test/yacc/pure_error.tab.c
index a52a1607b2808..91bbed670c151 100644
--- a/test/yacc/pure_error.tab.c
+++ b/test/yacc/pure_error.tab.c
@@ -202,8 +202,9 @@ static const char *const error_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -254,7 +255,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 258 "pure_error.tab.c"
+#line 259 "pure_error.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -321,6 +322,7 @@ YYPARSE_DECL()
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+ int yynerrs;
/* variables for the parser stack */
YYSTACKDATA yystack;
diff --git a/test/yacc/quote_calc-s.tab.c b/test/yacc/quote_calc-s.tab.c
index fa8fd00bb4f8a..fa9d703949975 100644
--- a/test/yacc/quote_calc-s.tab.c
+++ b/test/yacc/quote_calc-s.tab.c
@@ -291,13 +291,15 @@ static const char *const quote_calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -365,7 +367,7 @@ yylex(void) {
}
return( c );
}
-#line 369 "quote_calc-s.tab.c"
+#line 371 "quote_calc-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -624,7 +626,7 @@ case 18:
#line 70 "quote_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 628 "quote_calc-s.tab.c"
+#line 630 "quote_calc-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/quote_calc.tab.c b/test/yacc/quote_calc.tab.c
index c6a1220140a0f..3ddf2ff08f9ee 100644
--- a/test/yacc/quote_calc.tab.c
+++ b/test/yacc/quote_calc.tab.c
@@ -297,13 +297,15 @@ static const char *const quote_calc_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -371,7 +373,7 @@ yylex(void) {
}
return( c );
}
-#line 375 "quote_calc.tab.c"
+#line 377 "quote_calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -630,7 +632,7 @@ case 18:
#line 70 "quote_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 634 "quote_calc.tab.c"
+#line 636 "quote_calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/quote_calc2-s.tab.c b/test/yacc/quote_calc2-s.tab.c
index 505200e99fc07..43d268218cd3f 100644
--- a/test/yacc/quote_calc2-s.tab.c
+++ b/test/yacc/quote_calc2-s.tab.c
@@ -291,13 +291,15 @@ static const char *const quote_calc2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -365,7 +367,7 @@ yylex(void) {
}
return( c );
}
-#line 369 "quote_calc2-s.tab.c"
+#line 371 "quote_calc2-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -624,7 +626,7 @@ case 18:
#line 70 "quote_calc2.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 628 "quote_calc2-s.tab.c"
+#line 630 "quote_calc2-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/quote_calc2.tab.c b/test/yacc/quote_calc2.tab.c
index 3ff3dd19aedcf..1699b7fbafafa 100644
--- a/test/yacc/quote_calc2.tab.c
+++ b/test/yacc/quote_calc2.tab.c
@@ -297,13 +297,15 @@ static const char *const quote_calc2_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -371,7 +373,7 @@ yylex(void) {
}
return( c );
}
-#line 375 "quote_calc2.tab.c"
+#line 377 "quote_calc2.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -630,7 +632,7 @@ case 18:
#line 70 "quote_calc2.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 634 "quote_calc2.tab.c"
+#line 636 "quote_calc2.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/quote_calc3-s.tab.c b/test/yacc/quote_calc3-s.tab.c
index 1132ea37ea241..351d530dd5f3a 100644
--- a/test/yacc/quote_calc3-s.tab.c
+++ b/test/yacc/quote_calc3-s.tab.c
@@ -292,13 +292,15 @@ static const char *const quote_calc3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -366,7 +368,7 @@ yylex(void) {
}
return( c );
}
-#line 370 "quote_calc3-s.tab.c"
+#line 372 "quote_calc3-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -625,7 +627,7 @@ case 18:
#line 70 "quote_calc3.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 629 "quote_calc3-s.tab.c"
+#line 631 "quote_calc3-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/quote_calc3.tab.c b/test/yacc/quote_calc3.tab.c
index aff287b97af55..7479855b62b1c 100644
--- a/test/yacc/quote_calc3.tab.c
+++ b/test/yacc/quote_calc3.tab.c
@@ -292,13 +292,15 @@ static const char *const quote_calc3_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -366,7 +368,7 @@ yylex(void) {
}
return( c );
}
-#line 370 "quote_calc3.tab.c"
+#line 372 "quote_calc3.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -625,7 +627,7 @@ case 18:
#line 70 "quote_calc3.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 629 "quote_calc3.tab.c"
+#line 631 "quote_calc3.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/quote_calc4-s.tab.c b/test/yacc/quote_calc4-s.tab.c
index 16a0ebe147078..d3e6adc527202 100644
--- a/test/yacc/quote_calc4-s.tab.c
+++ b/test/yacc/quote_calc4-s.tab.c
@@ -292,13 +292,15 @@ static const char *const quote_calc4_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -366,7 +368,7 @@ yylex(void) {
}
return( c );
}
-#line 370 "quote_calc4-s.tab.c"
+#line 372 "quote_calc4-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -625,7 +627,7 @@ case 18:
#line 70 "quote_calc4.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 629 "quote_calc4-s.tab.c"
+#line 631 "quote_calc4-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/quote_calc4.tab.c b/test/yacc/quote_calc4.tab.c
index e442e1b6c50f4..db3aef21119d9 100644
--- a/test/yacc/quote_calc4.tab.c
+++ b/test/yacc/quote_calc4.tab.c
@@ -292,13 +292,15 @@ static const char *const quote_calc4_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -366,7 +368,7 @@ yylex(void) {
}
return( c );
}
-#line 370 "quote_calc4.tab.c"
+#line 372 "quote_calc4.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -625,7 +627,7 @@ case 18:
#line 70 "quote_calc4.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 629 "quote_calc4.tab.c"
+#line 631 "quote_calc4.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/yacc/rename_debug.c b/test/yacc/rename_debug.c
index e94d21619b6b8..909063a084fcc 100644
--- a/test/yacc/rename_debug.c
+++ b/test/yacc/rename_debug.c
@@ -66,13 +66,15 @@ static const char *const yyrule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -125,7 +127,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 130 "rename_debug.c"
+#line 132 "rename_debug.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/yacc/rename_debug.i b/test/yacc/rename_debug.i
index b7b801439e7a5..1e81e02e8f932 100644
--- a/test/yacc/rename_debug.i
+++ b/test/yacc/rename_debug.i
@@ -37,6 +37,10 @@ typedef int YYSTYPE;
# define YYLEX yylex()
#endif
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
@@ -47,10 +51,16 @@ typedef int YYSTYPE;
extern int YYPARSE_DECL();
+#ifndef YYDEBUG
+#define YYDEBUG 1
+#endif
+
+#if YYDEBUG
extern int yydebug;
-extern int yynerrs;
+#endif
extern int yyerrflag;
extern int yychar;
extern YYSTYPE yyval;
extern YYSTYPE yylval;
+extern int yynerrs;
diff --git a/test/yacc/stdin1.calc.c b/test/yacc/stdin1.calc.c
new file mode 100644
index 0000000000000..96b39d66ed384
--- /dev/null
+++ b/test/yacc/stdin1.calc.c
@@ -0,0 +1,595 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "(null)"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 31 "stdin1.calc.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 66 "(null)"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 280 "stdin1.calc.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "(null)"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "(null)"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "(null)"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "(null)"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "(null)"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "(null)"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "(null)"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "(null)"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "(null)"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "(null)"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "(null)"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "(null)"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "(null)"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "(null)"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "(null)"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 539 "stdin1.calc.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/stdin1.error b/test/yacc/stdin1.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/stdin1.error
diff --git a/test/yacc/stdin1.output b/test/yacc/stdin1.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/stdin1.output
diff --git a/test/yacc/stdin2.calc.c b/test/yacc/stdin2.calc.c
new file mode 100644
index 0000000000000..ce2de318446c3
--- /dev/null
+++ b/test/yacc/stdin2.calc.c
@@ -0,0 +1,595 @@
+/* original parser id follows */
+/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
+/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYCHECK "yyyymmdd"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+#define YYENOMEM (-2)
+#define YYEOF 0
+#define YYPREFIX "yy"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 31 "stdin2.calc.c"
+
+#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
+/* Default: YYSTYPE is the semantic value type. */
+typedef int YYSTYPE;
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+#if !(defined(yylex) || defined(YYSTATE))
+int YYLEX_DECL();
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+typedef short YYINT;
+static const YYINT yylhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const YYINT yylen[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const YYINT yydefred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const YYINT yydgoto[] = { 1,
+ 7, 8, 9,
+};
+static const YYINT yysindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const YYINT yyrindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const YYINT yygindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const YYINT yytable[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const YYINT yycheck[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, -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,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#define YYUNDFTOKEN 265
+#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
+#if YYDEBUG
+static const char *const yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,"'('","')'","'*'","'+'",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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
+};
+static const char *const yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+#if YYDEBUG
+int yydebug;
+#endif
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+
+#define YYINITSTACKSIZE 200
+
+typedef struct {
+ unsigned stacksize;
+ YYINT *s_base;
+ YYINT *s_mark;
+ YYINT *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 66 "calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 280 "stdin2.calc.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ YYINT *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return YYENOMEM;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = (int) (data->s_mark - data->s_base);
+ newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return YYENOMEM;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return YYENOMEM;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yym = 0;
+ yyn = 0;
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag != 0) goto yyinrecovery;
+
+ YYERROR_CALL("syntax error");
+
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == YYEOF) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym > 0)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+
+ switch (yyn)
+ {
+case 3:
+#line 28 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 32 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 34 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 38 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 40 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 42 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 44 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 46 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 48 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 50 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 52 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 54 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 56 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 61 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 63 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 539 "stdin2.calc.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
+#if YYDEBUG
+ if (yydebug)
+ {
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == YYEOF) goto yyaccept;
+ goto yyloop;
+ }
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
+ *++yystack.s_mark = (YYINT) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ YYERROR_CALL("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/yacc/stdin2.error b/test/yacc/stdin2.error
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/stdin2.error
diff --git a/test/yacc/stdin2.output b/test/yacc/stdin2.output
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/yacc/stdin2.output
diff --git a/test/yacc/varsyntax_calc1.tab.c b/test/yacc/varsyntax_calc1.tab.c
index fe78c83d03275..b66d44f2c1242 100644
--- a/test/yacc/varsyntax_calc1.tab.c
+++ b/test/yacc/varsyntax_calc1.tab.c
@@ -324,13 +324,15 @@ static const char *const varsyntax_calc1_rule[] = {
};
#endif
+#if YYDEBUG
int yydebug;
-int yynerrs;
+#endif
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
+int yynerrs;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -488,7 +490,7 @@ vdiv(double a, double b, INTERVAL v)
{
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
}
-#line 492 "varsyntax_calc1.tab.c"
+#line 494 "varsyntax_calc1.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -850,7 +852,7 @@ case 28:
yyval.vval = yystack.l_mark[-1].vval;
}
break;
-#line 854 "varsyntax_calc1.tab.c"
+#line 856 "varsyntax_calc1.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;