From 3c99f70cd01d77b64e3bdde86369a9379556f50c Mon Sep 17 00:00:00 2001 From: bapt Date: Sun, 20 Jul 2014 00:21:38 +0000 Subject: [PATCH] MFC: r257315, r260445, r264803 Update byacc to 20140422 git-svn-id: svn://svn.freebsd.org/base/stable/10@268899 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/byacc/CHANGES | 874 ++++- contrib/byacc/MANIFEST | 667 ++++ contrib/byacc/NOTES-btyacc-Changes | 385 +++ contrib/byacc/NOTES-btyacc-Disposition | 80 + contrib/byacc/README.BTYACC | 617 ++++ contrib/byacc/VERSION | 2 +- contrib/byacc/aclocal.m4 | 92 +- contrib/byacc/btyaccpar.c | 1246 ++++++++ contrib/byacc/btyaccpar.skel | 1125 +++++++ contrib/byacc/closure.c | 22 +- contrib/byacc/config.guess | 307 +- contrib/byacc/config.sub | 31 +- contrib/byacc/config_h.in | 9 + contrib/byacc/configure | 948 +++--- contrib/byacc/configure.in | 37 +- contrib/byacc/defs.h | 152 +- contrib/byacc/descrip.mms | 2 +- contrib/byacc/error.c | 120 +- contrib/byacc/graph.c | 8 +- contrib/byacc/lalr.c | 4 +- contrib/byacc/lr0.c | 84 +- contrib/byacc/main.c | 77 +- contrib/byacc/makefile.in | 62 +- contrib/byacc/mkpar.c | 27 +- contrib/byacc/mstring.c | 207 ++ contrib/byacc/output.c | 696 +++- contrib/byacc/package/byacc.spec | 4 +- contrib/byacc/package/debian/changelog | 25 + contrib/byacc/package/mingw-byacc.spec | 60 + contrib/byacc/package/pkgsrc/Makefile | 2 +- contrib/byacc/reader.c | 1698 ++++++++-- contrib/byacc/skel2c | 112 + contrib/byacc/symtab.c | 8 +- .../{code_error.tab.h => btyacc/big_b.error} | 0 contrib/byacc/test/btyacc/big_b.output | 19 + .../test/{error.tab.h => btyacc/big_l.error} | 0 contrib/byacc/test/btyacc/big_l.output | 19 + contrib/byacc/test/btyacc/btyacc_calc1.error | 1 + contrib/byacc/test/btyacc/btyacc_calc1.output | 949 ++++++ contrib/byacc/test/btyacc/btyacc_calc1.tab.c | 1732 ++++++++++ contrib/byacc/test/btyacc/btyacc_calc1.tab.h | 23 + contrib/byacc/test/btyacc/btyacc_demo.error | 1 + contrib/byacc/test/btyacc/btyacc_demo.output | 1360 ++++++++ contrib/byacc/test/btyacc/btyacc_demo.tab.c | 2331 ++++++++++++++ contrib/byacc/test/btyacc/btyacc_demo.tab.h | 36 + .../{pure_error.tab.h => btyacc/calc.error} | 0 contrib/byacc/test/btyacc/calc.output | 485 +++ contrib/byacc/test/btyacc/calc.tab.c | 1431 +++++++++ contrib/byacc/test/btyacc/calc.tab.h | 8 + contrib/byacc/test/btyacc/calc1.error | 2 + contrib/byacc/test/btyacc/calc1.output | 900 ++++++ contrib/byacc/test/btyacc/calc1.tab.c | 1677 ++++++++++ contrib/byacc/test/btyacc/calc1.tab.h | 23 + contrib/byacc/test/btyacc/calc2.error | 0 contrib/byacc/test/btyacc/calc2.output | 485 +++ contrib/byacc/test/btyacc/calc2.tab.c | 1444 +++++++++ contrib/byacc/test/btyacc/calc2.tab.h | 8 + contrib/byacc/test/btyacc/calc3.error | 0 contrib/byacc/test/btyacc/calc3.output | 485 +++ contrib/byacc/test/btyacc/calc3.tab.c | 1449 +++++++++ contrib/byacc/test/btyacc/calc3.tab.h | 8 + contrib/byacc/test/btyacc/code_calc.code.c | 1328 ++++++++ contrib/byacc/test/btyacc/code_calc.error | 0 contrib/byacc/test/btyacc/code_calc.output | 485 +++ contrib/byacc/test/btyacc/code_calc.tab.c | 137 + contrib/byacc/test/btyacc/code_calc.tab.h | 8 + contrib/byacc/test/btyacc/code_debug.c | 1125 +++++++ contrib/byacc/test/btyacc/code_debug.error | 0 contrib/byacc/test/btyacc/code_debug.h | 6 + contrib/byacc/test/btyacc/code_debug.i | 60 + contrib/byacc/test/btyacc/code_debug.output | 34 + contrib/byacc/test/btyacc/code_error.code.c | 1239 ++++++++ contrib/byacc/test/btyacc/code_error.error | 0 contrib/byacc/test/btyacc/code_error.output | 34 + contrib/byacc/test/btyacc/code_error.tab.c | 55 + contrib/byacc/test/btyacc/code_error.tab.h | 5 + contrib/byacc/test/btyacc/empty.error | 0 contrib/byacc/test/btyacc/empty.output | 28 + contrib/byacc/test/btyacc/empty.tab.c | 1254 ++++++++ contrib/byacc/test/btyacc/empty.tab.h | 5 + contrib/byacc/test/btyacc/err_inherit1.error | 3 + contrib/byacc/test/btyacc/err_inherit1.output | 0 contrib/byacc/test/btyacc/err_inherit1.tab.c | 15 + contrib/byacc/test/btyacc/err_inherit1.tab.h | 0 contrib/byacc/test/btyacc/err_inherit2.error | 5 + contrib/byacc/test/btyacc/err_inherit2.output | 0 contrib/byacc/test/btyacc/err_inherit2.tab.c | 15 + contrib/byacc/test/btyacc/err_inherit2.tab.h | 0 contrib/byacc/test/btyacc/err_inherit3.error | 23 + contrib/byacc/test/btyacc/err_inherit3.output | 229 ++ contrib/byacc/test/btyacc/err_inherit3.tab.c | 1414 +++++++++ contrib/byacc/test/btyacc/err_inherit3.tab.h | 25 + contrib/byacc/test/btyacc/err_inherit4.error | 13 + contrib/byacc/test/btyacc/err_inherit4.output | 178 ++ contrib/byacc/test/btyacc/err_inherit4.tab.c | 1403 ++++++++ contrib/byacc/test/btyacc/err_inherit4.tab.h | 25 + contrib/byacc/test/btyacc/err_inherit5.error | 1 + contrib/byacc/test/btyacc/err_inherit5.output | 0 contrib/byacc/test/btyacc/err_inherit5.tab.c | 15 + contrib/byacc/test/btyacc/err_inherit5.tab.h | 0 contrib/byacc/test/btyacc/err_syntax1.error | 3 + contrib/byacc/test/btyacc/err_syntax1.output | 0 contrib/byacc/test/btyacc/err_syntax1.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax1.tab.h | 0 contrib/byacc/test/btyacc/err_syntax10.error | 3 + contrib/byacc/test/btyacc/err_syntax10.output | 37 + contrib/byacc/test/btyacc/err_syntax10.tab.c | 1253 ++++++++ contrib/byacc/test/btyacc/err_syntax10.tab.h | 5 + contrib/byacc/test/btyacc/err_syntax11.error | 1 + contrib/byacc/test/btyacc/err_syntax11.output | 35 + contrib/byacc/test/btyacc/err_syntax11.tab.c | 1259 ++++++++ contrib/byacc/test/btyacc/err_syntax11.tab.h | 5 + contrib/byacc/test/btyacc/err_syntax12.error | 1 + contrib/byacc/test/btyacc/err_syntax12.output | 35 + contrib/byacc/test/btyacc/err_syntax12.tab.c | 1265 ++++++++ contrib/byacc/test/btyacc/err_syntax12.tab.h | 6 + contrib/byacc/test/btyacc/err_syntax13.error | 1 + contrib/byacc/test/btyacc/err_syntax13.output | 0 contrib/byacc/test/btyacc/err_syntax13.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax13.tab.h | 0 contrib/byacc/test/btyacc/err_syntax14.error | 2 + contrib/byacc/test/btyacc/err_syntax14.output | 0 contrib/byacc/test/btyacc/err_syntax14.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax14.tab.h | 0 contrib/byacc/test/btyacc/err_syntax15.error | 1 + contrib/byacc/test/btyacc/err_syntax15.output | 0 contrib/byacc/test/btyacc/err_syntax15.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax15.tab.h | 0 contrib/byacc/test/btyacc/err_syntax16.error | 1 + contrib/byacc/test/btyacc/err_syntax16.output | 0 contrib/byacc/test/btyacc/err_syntax16.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax16.tab.h | 0 contrib/byacc/test/btyacc/err_syntax17.error | 3 + contrib/byacc/test/btyacc/err_syntax17.output | 0 contrib/byacc/test/btyacc/err_syntax17.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax17.tab.h | 0 contrib/byacc/test/btyacc/err_syntax18.error | 1 + contrib/byacc/test/btyacc/err_syntax18.output | 52 + contrib/byacc/test/btyacc/err_syntax18.tab.c | 1266 ++++++++ contrib/byacc/test/btyacc/err_syntax18.tab.h | 5 + contrib/byacc/test/btyacc/err_syntax19.error | 3 + contrib/byacc/test/btyacc/err_syntax19.output | 0 contrib/byacc/test/btyacc/err_syntax19.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax19.tab.h | 0 contrib/byacc/test/btyacc/err_syntax2.error | 3 + contrib/byacc/test/btyacc/err_syntax2.output | 0 contrib/byacc/test/btyacc/err_syntax2.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax2.tab.h | 0 contrib/byacc/test/btyacc/err_syntax20.error | 1 + contrib/byacc/test/btyacc/err_syntax20.output | 51 + contrib/byacc/test/btyacc/err_syntax20.tab.c | 1261 ++++++++ contrib/byacc/test/btyacc/err_syntax20.tab.h | 6 + contrib/byacc/test/btyacc/err_syntax21.error | 1 + contrib/byacc/test/btyacc/err_syntax21.output | 0 contrib/byacc/test/btyacc/err_syntax21.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax21.tab.h | 0 contrib/byacc/test/btyacc/err_syntax22.error | 1 + contrib/byacc/test/btyacc/err_syntax22.output | 0 contrib/byacc/test/btyacc/err_syntax22.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax22.tab.h | 0 contrib/byacc/test/btyacc/err_syntax23.error | 1 + contrib/byacc/test/btyacc/err_syntax23.output | 0 contrib/byacc/test/btyacc/err_syntax23.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax23.tab.h | 0 contrib/byacc/test/btyacc/err_syntax24.error | 2 + contrib/byacc/test/btyacc/err_syntax24.output | 0 contrib/byacc/test/btyacc/err_syntax24.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax24.tab.h | 0 contrib/byacc/test/btyacc/err_syntax25.error | 3 + contrib/byacc/test/btyacc/err_syntax25.output | 0 contrib/byacc/test/btyacc/err_syntax25.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax25.tab.h | 0 contrib/byacc/test/btyacc/err_syntax26.error | 1 + contrib/byacc/test/btyacc/err_syntax26.output | 0 contrib/byacc/test/btyacc/err_syntax26.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax26.tab.h | 0 contrib/byacc/test/btyacc/err_syntax27.error | 1 + contrib/byacc/test/btyacc/err_syntax27.output | 0 contrib/byacc/test/btyacc/err_syntax27.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax27.tab.h | 0 contrib/byacc/test/btyacc/err_syntax3.error | 3 + contrib/byacc/test/btyacc/err_syntax3.output | 0 contrib/byacc/test/btyacc/err_syntax3.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax3.tab.h | 0 contrib/byacc/test/btyacc/err_syntax4.error | 3 + contrib/byacc/test/btyacc/err_syntax4.output | 0 contrib/byacc/test/btyacc/err_syntax4.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax4.tab.h | 0 contrib/byacc/test/btyacc/err_syntax5.error | 3 + contrib/byacc/test/btyacc/err_syntax5.output | 0 contrib/byacc/test/btyacc/err_syntax5.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax5.tab.h | 0 contrib/byacc/test/btyacc/err_syntax6.error | 3 + contrib/byacc/test/btyacc/err_syntax6.output | 0 contrib/byacc/test/btyacc/err_syntax6.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax6.tab.h | 0 contrib/byacc/test/btyacc/err_syntax7.error | 3 + contrib/byacc/test/btyacc/err_syntax7.output | 0 contrib/byacc/test/btyacc/err_syntax7.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax7.tab.h | 0 contrib/byacc/test/btyacc/err_syntax7a.error | 3 + contrib/byacc/test/btyacc/err_syntax7a.output | 0 contrib/byacc/test/btyacc/err_syntax7a.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax7a.tab.h | 0 contrib/byacc/test/btyacc/err_syntax7b.error | 3 + contrib/byacc/test/btyacc/err_syntax7b.output | 0 contrib/byacc/test/btyacc/err_syntax7b.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax7b.tab.h | 0 contrib/byacc/test/btyacc/err_syntax8.error | 1 + contrib/byacc/test/btyacc/err_syntax8.output | 0 contrib/byacc/test/btyacc/err_syntax8.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax8.tab.h | 0 contrib/byacc/test/btyacc/err_syntax8a.error | 1 + contrib/byacc/test/btyacc/err_syntax8a.output | 0 contrib/byacc/test/btyacc/err_syntax8a.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax8a.tab.h | 0 contrib/byacc/test/btyacc/err_syntax9.error | 1 + contrib/byacc/test/btyacc/err_syntax9.output | 0 contrib/byacc/test/btyacc/err_syntax9.tab.c | 15 + contrib/byacc/test/btyacc/err_syntax9.tab.h | 0 contrib/byacc/test/btyacc/error.error | 0 contrib/byacc/test/btyacc/error.output | 34 + contrib/byacc/test/btyacc/error.tab.c | 1258 ++++++++ contrib/byacc/test/btyacc/error.tab.h | 5 + contrib/byacc/test/btyacc/grammar.dot | 906 ++++++ contrib/byacc/test/btyacc/grammar.error | 1 + contrib/byacc/test/btyacc/grammar.output | 2304 ++++++++++++++ contrib/byacc/test/btyacc/grammar.tab.c | 2813 +++++++++++++++++ contrib/byacc/test/btyacc/grammar.tab.h | 40 + contrib/byacc/test/btyacc/help.error | 0 contrib/byacc/test/btyacc/help.output | 19 + contrib/byacc/test/btyacc/inherit0.error | 0 contrib/byacc/test/btyacc/inherit0.output | 165 + contrib/byacc/test/btyacc/inherit0.tab.c | 1321 ++++++++ contrib/byacc/test/btyacc/inherit0.tab.h | 10 + contrib/byacc/test/btyacc/inherit1.error | 0 contrib/byacc/test/btyacc/inherit1.output | 165 + contrib/byacc/test/btyacc/inherit1.tab.c | 1346 ++++++++ contrib/byacc/test/btyacc/inherit1.tab.h | 25 + contrib/byacc/test/btyacc/inherit2.error | 0 contrib/byacc/test/btyacc/inherit2.output | 199 ++ contrib/byacc/test/btyacc/inherit2.tab.c | 1409 +++++++++ contrib/byacc/test/btyacc/inherit2.tab.h | 25 + contrib/byacc/test/btyacc/no_b_opt.error | 0 contrib/byacc/test/btyacc/no_b_opt.output | 19 + contrib/byacc/test/btyacc/no_b_opt1.error | 0 contrib/byacc/test/btyacc/no_b_opt1.output | 1 + contrib/byacc/test/btyacc/no_code_c.error | 0 contrib/byacc/test/btyacc/no_code_c.output | 1 + contrib/byacc/test/btyacc/no_defines.error | 0 contrib/byacc/test/btyacc/no_defines.output | 1 + contrib/byacc/test/btyacc/no_graph.error | 0 contrib/byacc/test/btyacc/no_graph.output | 1 + contrib/byacc/test/btyacc/no_include.error | 0 contrib/byacc/test/btyacc/no_include.output | 1 + contrib/byacc/test/btyacc/no_opts.error | 0 contrib/byacc/test/btyacc/no_opts.output | 1 + contrib/byacc/test/btyacc/no_output.error | 0 contrib/byacc/test/btyacc/no_output.output | 1 + contrib/byacc/test/btyacc/no_output1.error | 0 contrib/byacc/test/btyacc/no_output1.output | 1 + contrib/byacc/test/btyacc/no_output2.error | 0 contrib/byacc/test/btyacc/no_output2.output | 19 + contrib/byacc/test/btyacc/no_p_opt.error | 0 contrib/byacc/test/btyacc/no_p_opt.output | 19 + contrib/byacc/test/btyacc/no_p_opt1.error | 0 contrib/byacc/test/btyacc/no_p_opt1.output | 1 + contrib/byacc/test/btyacc/no_verbose.error | 0 contrib/byacc/test/btyacc/no_verbose.output | 1 + contrib/byacc/test/btyacc/nostdin.error | 0 contrib/byacc/test/btyacc/nostdin.output | 19 + contrib/byacc/test/btyacc/ok_syntax1.error | 0 contrib/byacc/test/btyacc/ok_syntax1.output | 511 +++ contrib/byacc/test/btyacc/ok_syntax1.tab.c | 1472 +++++++++ contrib/byacc/test/btyacc/ok_syntax1.tab.h | 35 + contrib/byacc/test/btyacc/pure_calc.error | 0 contrib/byacc/test/btyacc/pure_calc.output | 485 +++ contrib/byacc/test/btyacc/pure_calc.tab.c | 1445 +++++++++ contrib/byacc/test/btyacc/pure_calc.tab.h | 8 + contrib/byacc/test/btyacc/pure_error.error | 0 contrib/byacc/test/btyacc/pure_error.output | 34 + contrib/byacc/test/btyacc/pure_error.tab.c | 1274 ++++++++ contrib/byacc/test/btyacc/pure_error.tab.h | 5 + contrib/byacc/test/btyacc/quote_calc-s.error | 1 + contrib/byacc/test/btyacc/quote_calc-s.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc-s.tab.c | 1445 +++++++++ contrib/byacc/test/btyacc/quote_calc-s.tab.h | 14 + contrib/byacc/test/btyacc/quote_calc.error | 1 + contrib/byacc/test/btyacc/quote_calc.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc.tab.c | 1451 +++++++++ contrib/byacc/test/btyacc/quote_calc.tab.h | 20 + contrib/byacc/test/btyacc/quote_calc2-s.error | 1 + .../byacc/test/btyacc/quote_calc2-s.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc2-s.tab.c | 1445 +++++++++ contrib/byacc/test/btyacc/quote_calc2-s.tab.h | 14 + contrib/byacc/test/btyacc/quote_calc2.error | 1 + contrib/byacc/test/btyacc/quote_calc2.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc2.tab.c | 1451 +++++++++ contrib/byacc/test/btyacc/quote_calc2.tab.h | 20 + contrib/byacc/test/btyacc/quote_calc3-s.error | 1 + .../byacc/test/btyacc/quote_calc3-s.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc3-s.tab.c | 1446 +++++++++ contrib/byacc/test/btyacc/quote_calc3-s.tab.h | 14 + contrib/byacc/test/btyacc/quote_calc3.error | 1 + contrib/byacc/test/btyacc/quote_calc3.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc3.tab.c | 1446 +++++++++ contrib/byacc/test/btyacc/quote_calc3.tab.h | 14 + contrib/byacc/test/btyacc/quote_calc4-s.error | 1 + .../byacc/test/btyacc/quote_calc4-s.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc4-s.tab.c | 1446 +++++++++ contrib/byacc/test/btyacc/quote_calc4-s.tab.h | 14 + contrib/byacc/test/btyacc/quote_calc4.error | 1 + contrib/byacc/test/btyacc/quote_calc4.output | 593 ++++ contrib/byacc/test/btyacc/quote_calc4.tab.c | 1446 +++++++++ contrib/byacc/test/btyacc/quote_calc4.tab.h | 14 + contrib/byacc/test/btyacc/rename_debug.c | 1121 +++++++ contrib/byacc/test/btyacc/rename_debug.error | 0 contrib/byacc/test/btyacc/rename_debug.h | 6 + contrib/byacc/test/btyacc/rename_debug.i | 60 + contrib/byacc/test/btyacc/rename_debug.output | 34 + .../byacc/test/btyacc/varsyntax_calc1.error | 2 + .../byacc/test/btyacc/varsyntax_calc1.output | 900 ++++++ .../byacc/test/btyacc/varsyntax_calc1.tab.c | 1678 ++++++++++ .../byacc/test/btyacc/varsyntax_calc1.tab.h | 23 + contrib/byacc/test/btyacc_calc1.y | 324 ++ contrib/byacc/test/btyacc_demo.y | 226 ++ contrib/byacc/test/calc2.y | 4 + contrib/byacc/test/calc3.y | 4 + contrib/byacc/test/code_debug.y | 36 + contrib/byacc/test/code_error.tab.c | 118 - contrib/byacc/test/empty.y | 24 + contrib/byacc/test/err_inherit1.y | 64 + contrib/byacc/test/err_inherit2.y | 80 + contrib/byacc/test/err_inherit3.y | 80 + contrib/byacc/test/err_inherit4.y | 82 + contrib/byacc/test/err_inherit5.y | 80 + contrib/byacc/test/err_syntax1.y | 28 + contrib/byacc/test/err_syntax10.y | 32 + contrib/byacc/test/err_syntax11.y | 32 + contrib/byacc/test/err_syntax12.y | 32 + contrib/byacc/test/err_syntax13.y | 32 + contrib/byacc/test/err_syntax14.y | 32 + contrib/byacc/test/err_syntax15.y | 32 + contrib/byacc/test/err_syntax16.y | 40 + contrib/byacc/test/err_syntax17.y | 30 + contrib/byacc/test/err_syntax18.y | 33 + contrib/byacc/test/err_syntax19.y | 33 + contrib/byacc/test/err_syntax2.y | 28 + contrib/byacc/test/err_syntax20.y | 36 + contrib/byacc/test/err_syntax21.y | 36 + contrib/byacc/test/err_syntax22.y | 44 + contrib/byacc/test/err_syntax23.y | 46 + contrib/byacc/test/err_syntax24.y | 46 + contrib/byacc/test/err_syntax25.y | 51 + contrib/byacc/test/err_syntax26.y | 6 + contrib/byacc/test/err_syntax27.y | 127 + contrib/byacc/test/err_syntax3.y | 31 + contrib/byacc/test/err_syntax4.y | 28 + contrib/byacc/test/err_syntax5.y | 33 + contrib/byacc/test/err_syntax6.y | 31 + contrib/byacc/test/err_syntax7.y | 31 + contrib/byacc/test/err_syntax7a.y | 31 + contrib/byacc/test/err_syntax7b.y | 31 + contrib/byacc/test/err_syntax8.y | 31 + contrib/byacc/test/err_syntax8a.y | 31 + contrib/byacc/test/err_syntax9.y | 32 + contrib/byacc/test/ftp.output | 1625 ---------- contrib/byacc/test/ftp.tab.c | 2010 ------------ contrib/byacc/test/ftp.tab.h | 76 - contrib/byacc/test/ftp.y | 1254 -------- contrib/byacc/test/inherit0.y | 48 + contrib/byacc/test/inherit1.y | 76 + contrib/byacc/test/inherit2.y | 80 + contrib/byacc/test/ok_syntax1.y | 155 + contrib/byacc/test/run_lint.sh | 12 +- contrib/byacc/test/run_make.sh | 97 +- contrib/byacc/test/run_test.sh | 208 +- contrib/byacc/test/varsyntax_calc1.y | 307 ++ contrib/byacc/test/yacc/big_b.error | 0 contrib/byacc/test/yacc/big_b.output | 20 + contrib/byacc/test/yacc/big_l.error | 0 contrib/byacc/test/yacc/big_l.output | 20 + contrib/byacc/test/yacc/calc.error | 0 contrib/byacc/test/{ => yacc}/calc.output | 0 contrib/byacc/test/{ => yacc}/calc.tab.c | 103 +- contrib/byacc/test/{ => yacc}/calc.tab.h | 0 contrib/byacc/test/yacc/calc1.error | 2 + contrib/byacc/test/{ => yacc}/calc1.output | 0 contrib/byacc/test/{ => yacc}/calc1.tab.c | 99 +- contrib/byacc/test/{ => yacc}/calc1.tab.h | 0 contrib/byacc/test/yacc/calc2.error | 0 contrib/byacc/test/{ => yacc}/calc2.output | 0 contrib/byacc/test/{ => yacc}/calc2.tab.c | 107 +- contrib/byacc/test/{ => yacc}/calc2.tab.h | 0 contrib/byacc/test/yacc/calc3.error | 0 contrib/byacc/test/{ => yacc}/calc3.output | 0 contrib/byacc/test/{ => yacc}/calc3.tab.c | 107 +- contrib/byacc/test/{ => yacc}/calc3.tab.h | 0 .../byacc/test/{ => yacc}/code_calc.code.c | 215 +- contrib/byacc/test/yacc/code_calc.error | 0 .../byacc/test/{ => yacc}/code_calc.output | 0 contrib/byacc/test/{ => yacc}/code_calc.tab.c | 106 +- contrib/byacc/test/{ => yacc}/code_calc.tab.h | 0 .../byacc/test/{ => yacc}/code_error.code.c | 197 +- contrib/byacc/test/yacc/code_error.error | 0 .../byacc/test/{ => yacc}/code_error.output | 0 contrib/byacc/test/yacc/code_error.tab.c | 44 + contrib/byacc/test/yacc/code_error.tab.h | 0 contrib/byacc/test/yacc/empty.error | 0 contrib/byacc/test/yacc/empty.output | 21 + contrib/byacc/test/yacc/empty.tab.c | 503 +++ contrib/byacc/test/yacc/empty.tab.h | 0 contrib/byacc/test/yacc/err_syntax1.error | 3 + contrib/byacc/test/yacc/err_syntax1.output | 0 contrib/byacc/test/yacc/err_syntax1.tab.c | 15 + contrib/byacc/test/yacc/err_syntax1.tab.h | 0 contrib/byacc/test/yacc/err_syntax10.error | 3 + contrib/byacc/test/yacc/err_syntax10.output | 27 + contrib/byacc/test/yacc/err_syntax10.tab.c | 502 +++ contrib/byacc/test/yacc/err_syntax10.tab.h | 0 contrib/byacc/test/yacc/err_syntax11.error | 1 + contrib/byacc/test/yacc/err_syntax11.output | 27 + contrib/byacc/test/yacc/err_syntax11.tab.c | 508 +++ contrib/byacc/test/yacc/err_syntax11.tab.h | 0 contrib/byacc/test/yacc/err_syntax12.error | 1 + contrib/byacc/test/yacc/err_syntax12.output | 27 + contrib/byacc/test/yacc/err_syntax12.tab.c | 514 +++ contrib/byacc/test/yacc/err_syntax12.tab.h | 1 + contrib/byacc/test/yacc/err_syntax13.error | 1 + contrib/byacc/test/yacc/err_syntax13.output | 0 contrib/byacc/test/yacc/err_syntax13.tab.c | 15 + contrib/byacc/test/yacc/err_syntax13.tab.h | 0 contrib/byacc/test/yacc/err_syntax14.error | 2 + contrib/byacc/test/yacc/err_syntax14.output | 0 contrib/byacc/test/yacc/err_syntax14.tab.c | 15 + contrib/byacc/test/yacc/err_syntax14.tab.h | 0 contrib/byacc/test/yacc/err_syntax15.error | 1 + contrib/byacc/test/yacc/err_syntax15.output | 0 contrib/byacc/test/yacc/err_syntax15.tab.c | 15 + contrib/byacc/test/yacc/err_syntax15.tab.h | 0 contrib/byacc/test/yacc/err_syntax16.error | 1 + contrib/byacc/test/yacc/err_syntax16.output | 0 contrib/byacc/test/yacc/err_syntax16.tab.c | 15 + contrib/byacc/test/yacc/err_syntax16.tab.h | 0 contrib/byacc/test/yacc/err_syntax17.error | 3 + contrib/byacc/test/yacc/err_syntax17.output | 0 contrib/byacc/test/yacc/err_syntax17.tab.c | 15 + contrib/byacc/test/yacc/err_syntax17.tab.h | 0 contrib/byacc/test/yacc/err_syntax18.error | 1 + contrib/byacc/test/yacc/err_syntax18.output | 43 + contrib/byacc/test/yacc/err_syntax18.tab.c | 515 +++ contrib/byacc/test/yacc/err_syntax18.tab.h | 0 contrib/byacc/test/yacc/err_syntax19.error | 3 + contrib/byacc/test/yacc/err_syntax19.output | 0 contrib/byacc/test/yacc/err_syntax19.tab.c | 15 + contrib/byacc/test/yacc/err_syntax19.tab.h | 0 contrib/byacc/test/yacc/err_syntax2.error | 3 + contrib/byacc/test/yacc/err_syntax2.output | 0 contrib/byacc/test/yacc/err_syntax2.tab.c | 15 + contrib/byacc/test/yacc/err_syntax2.tab.h | 0 contrib/byacc/test/yacc/err_syntax20.error | 1 + contrib/byacc/test/yacc/err_syntax20.output | 41 + contrib/byacc/test/yacc/err_syntax20.tab.c | 511 +++ contrib/byacc/test/yacc/err_syntax20.tab.h | 1 + contrib/byacc/test/yacc/err_syntax21.error | 1 + contrib/byacc/test/yacc/err_syntax21.output | 0 contrib/byacc/test/yacc/err_syntax21.tab.c | 15 + contrib/byacc/test/yacc/err_syntax21.tab.h | 0 contrib/byacc/test/yacc/err_syntax22.error | 1 + contrib/byacc/test/yacc/err_syntax22.output | 0 contrib/byacc/test/yacc/err_syntax22.tab.c | 15 + contrib/byacc/test/yacc/err_syntax22.tab.h | 0 contrib/byacc/test/yacc/err_syntax23.error | 1 + contrib/byacc/test/yacc/err_syntax23.output | 0 contrib/byacc/test/yacc/err_syntax23.tab.c | 15 + contrib/byacc/test/yacc/err_syntax23.tab.h | 0 contrib/byacc/test/yacc/err_syntax24.error | 2 + contrib/byacc/test/yacc/err_syntax24.output | 0 contrib/byacc/test/yacc/err_syntax24.tab.c | 15 + contrib/byacc/test/yacc/err_syntax24.tab.h | 0 contrib/byacc/test/yacc/err_syntax25.error | 3 + contrib/byacc/test/yacc/err_syntax25.output | 0 contrib/byacc/test/yacc/err_syntax25.tab.c | 15 + contrib/byacc/test/yacc/err_syntax25.tab.h | 0 contrib/byacc/test/yacc/err_syntax26.error | 1 + contrib/byacc/test/yacc/err_syntax26.output | 0 contrib/byacc/test/yacc/err_syntax26.tab.c | 15 + contrib/byacc/test/yacc/err_syntax26.tab.h | 0 contrib/byacc/test/yacc/err_syntax27.error | 1 + contrib/byacc/test/yacc/err_syntax27.output | 0 contrib/byacc/test/yacc/err_syntax27.tab.c | 15 + contrib/byacc/test/yacc/err_syntax27.tab.h | 0 contrib/byacc/test/yacc/err_syntax3.error | 3 + contrib/byacc/test/yacc/err_syntax3.output | 0 contrib/byacc/test/yacc/err_syntax3.tab.c | 15 + contrib/byacc/test/yacc/err_syntax3.tab.h | 0 contrib/byacc/test/yacc/err_syntax4.error | 3 + contrib/byacc/test/yacc/err_syntax4.output | 0 contrib/byacc/test/yacc/err_syntax4.tab.c | 15 + contrib/byacc/test/yacc/err_syntax4.tab.h | 0 contrib/byacc/test/yacc/err_syntax5.error | 3 + contrib/byacc/test/yacc/err_syntax5.output | 0 contrib/byacc/test/yacc/err_syntax5.tab.c | 15 + contrib/byacc/test/yacc/err_syntax5.tab.h | 0 contrib/byacc/test/yacc/err_syntax6.error | 3 + contrib/byacc/test/yacc/err_syntax6.output | 0 contrib/byacc/test/yacc/err_syntax6.tab.c | 15 + contrib/byacc/test/yacc/err_syntax6.tab.h | 0 contrib/byacc/test/yacc/err_syntax7.error | 3 + contrib/byacc/test/yacc/err_syntax7.output | 0 contrib/byacc/test/yacc/err_syntax7.tab.c | 15 + contrib/byacc/test/yacc/err_syntax7.tab.h | 0 contrib/byacc/test/yacc/err_syntax7a.error | 3 + contrib/byacc/test/yacc/err_syntax7a.output | 0 contrib/byacc/test/yacc/err_syntax7a.tab.c | 15 + contrib/byacc/test/yacc/err_syntax7a.tab.h | 0 contrib/byacc/test/yacc/err_syntax7b.error | 3 + contrib/byacc/test/yacc/err_syntax7b.output | 0 contrib/byacc/test/yacc/err_syntax7b.tab.c | 15 + contrib/byacc/test/yacc/err_syntax7b.tab.h | 0 contrib/byacc/test/yacc/err_syntax8.error | 1 + contrib/byacc/test/yacc/err_syntax8.output | 0 contrib/byacc/test/yacc/err_syntax8.tab.c | 15 + contrib/byacc/test/yacc/err_syntax8.tab.h | 0 contrib/byacc/test/yacc/err_syntax8a.error | 1 + contrib/byacc/test/yacc/err_syntax8a.output | 0 contrib/byacc/test/yacc/err_syntax8a.tab.c | 15 + contrib/byacc/test/yacc/err_syntax8a.tab.h | 0 contrib/byacc/test/yacc/err_syntax9.error | 1 + contrib/byacc/test/yacc/err_syntax9.output | 0 contrib/byacc/test/yacc/err_syntax9.tab.c | 15 + contrib/byacc/test/yacc/err_syntax9.tab.h | 0 contrib/byacc/test/yacc/error.error | 0 contrib/byacc/test/{ => yacc}/error.output | 0 contrib/byacc/test/{ => yacc}/error.tab.c | 111 +- contrib/byacc/test/yacc/error.tab.h | 0 contrib/byacc/test/yacc/grammar.dot | 906 ++++++ contrib/byacc/test/yacc/grammar.error | 1 + contrib/byacc/test/{ => yacc}/grammar.output | 0 contrib/byacc/test/{ => yacc}/grammar.tab.c | 101 +- contrib/byacc/test/{ => yacc}/grammar.tab.h | 0 contrib/byacc/test/yacc/help.error | 0 contrib/byacc/test/yacc/help.output | 19 + contrib/byacc/test/yacc/no_b_opt.error | 0 contrib/byacc/test/yacc/no_b_opt.output | 19 + contrib/byacc/test/yacc/no_b_opt1.error | 0 contrib/byacc/test/yacc/no_b_opt1.output | 1 + contrib/byacc/test/yacc/no_code_c.error | 0 contrib/byacc/test/yacc/no_code_c.output | 1 + contrib/byacc/test/yacc/no_defines.error | 0 contrib/byacc/test/yacc/no_defines.output | 1 + contrib/byacc/test/yacc/no_graph.error | 0 contrib/byacc/test/yacc/no_graph.output | 1 + contrib/byacc/test/yacc/no_include.error | 0 contrib/byacc/test/yacc/no_include.output | 1 + contrib/byacc/test/yacc/no_opts.error | 0 contrib/byacc/test/yacc/no_opts.output | 1 + contrib/byacc/test/yacc/no_output.error | 0 contrib/byacc/test/yacc/no_output.output | 1 + contrib/byacc/test/yacc/no_output1.error | 0 contrib/byacc/test/yacc/no_output1.output | 1 + contrib/byacc/test/yacc/no_output2.error | 0 contrib/byacc/test/yacc/no_output2.output | 19 + contrib/byacc/test/yacc/no_p_opt.error | 0 contrib/byacc/test/yacc/no_p_opt.output | 19 + contrib/byacc/test/yacc/no_p_opt1.error | 0 contrib/byacc/test/yacc/no_p_opt1.output | 1 + contrib/byacc/test/yacc/no_verbose.error | 0 contrib/byacc/test/yacc/no_verbose.output | 1 + contrib/byacc/test/yacc/nostdin.error | 0 contrib/byacc/test/yacc/nostdin.output | 19 + contrib/byacc/test/yacc/ok_syntax1.error | 0 contrib/byacc/test/yacc/ok_syntax1.output | 461 +++ contrib/byacc/test/yacc/ok_syntax1.tab.c | 716 +++++ contrib/byacc/test/yacc/ok_syntax1.tab.h | 30 + contrib/byacc/test/yacc/pure_calc.error | 0 .../byacc/test/{ => yacc}/pure_calc.output | 0 contrib/byacc/test/{ => yacc}/pure_calc.tab.c | 103 +- contrib/byacc/test/{ => yacc}/pure_calc.tab.h | 0 contrib/byacc/test/yacc/pure_error.error | 0 .../byacc/test/{ => yacc}/pure_error.output | 0 .../byacc/test/{ => yacc}/pure_error.tab.c | 111 +- contrib/byacc/test/yacc/pure_error.tab.h | 0 contrib/byacc/test/yacc/quote_calc-s.error | 1 + .../byacc/test/{ => yacc}/quote_calc-s.output | 0 .../byacc/test/{ => yacc}/quote_calc-s.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc-s.tab.h | 0 contrib/byacc/test/yacc/quote_calc.error | 1 + .../byacc/test/{ => yacc}/quote_calc.output | 0 .../byacc/test/{ => yacc}/quote_calc.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc.tab.h | 0 contrib/byacc/test/yacc/quote_calc2-s.error | 1 + .../test/{ => yacc}/quote_calc2-s.output | 0 .../byacc/test/{ => yacc}/quote_calc2-s.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc2-s.tab.h | 0 contrib/byacc/test/yacc/quote_calc2.error | 1 + .../byacc/test/{ => yacc}/quote_calc2.output | 0 .../byacc/test/{ => yacc}/quote_calc2.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc2.tab.h | 0 contrib/byacc/test/yacc/quote_calc3-s.error | 1 + .../test/{ => yacc}/quote_calc3-s.output | 0 .../byacc/test/{ => yacc}/quote_calc3-s.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc3-s.tab.h | 0 contrib/byacc/test/yacc/quote_calc3.error | 1 + .../byacc/test/{ => yacc}/quote_calc3.output | 0 .../byacc/test/{ => yacc}/quote_calc3.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc3.tab.h | 0 contrib/byacc/test/yacc/quote_calc4-s.error | 1 + .../test/{ => yacc}/quote_calc4-s.output | 0 .../byacc/test/{ => yacc}/quote_calc4-s.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc4-s.tab.h | 0 contrib/byacc/test/yacc/quote_calc4.error | 1 + .../byacc/test/{ => yacc}/quote_calc4.output | 0 .../byacc/test/{ => yacc}/quote_calc4.tab.c | 104 +- .../byacc/test/{ => yacc}/quote_calc4.tab.h | 0 contrib/byacc/test/yacc/rename_debug.c | 388 +++ contrib/byacc/test/yacc/rename_debug.error | 0 contrib/byacc/test/yacc/rename_debug.h | 1 + contrib/byacc/test/yacc/rename_debug.i | 56 + contrib/byacc/test/yacc/rename_debug.output | 27 + contrib/byacc/test/yacc/varsyntax_calc1.error | 2 + .../byacc/test/yacc/varsyntax_calc1.output | 877 +++++ contrib/byacc/test/yacc/varsyntax_calc1.tab.c | 915 ++++++ contrib/byacc/test/yacc/varsyntax_calc1.tab.h | 18 + contrib/byacc/verbose.c | 44 +- contrib/byacc/vmsbuild.com | 6 +- contrib/byacc/yacc.1 | 157 +- contrib/byacc/{skeleton.c => yaccpar.c} | 111 +- contrib/byacc/yaccpar.skel | 353 +++ usr.bin/yacc/Makefile | 6 +- 630 files changed, 90227 insertions(+), 7552 deletions(-) create mode 100644 contrib/byacc/MANIFEST create mode 100644 contrib/byacc/NOTES-btyacc-Changes create mode 100644 contrib/byacc/NOTES-btyacc-Disposition create mode 100644 contrib/byacc/README.BTYACC create mode 100644 contrib/byacc/btyaccpar.c create mode 100644 contrib/byacc/btyaccpar.skel create mode 100644 contrib/byacc/mstring.c create mode 100644 contrib/byacc/package/mingw-byacc.spec create mode 100644 contrib/byacc/skel2c rename contrib/byacc/test/{code_error.tab.h => btyacc/big_b.error} (100%) create mode 100644 contrib/byacc/test/btyacc/big_b.output rename contrib/byacc/test/{error.tab.h => btyacc/big_l.error} (100%) create mode 100644 contrib/byacc/test/btyacc/big_l.output create mode 100644 contrib/byacc/test/btyacc/btyacc_calc1.error create mode 100644 contrib/byacc/test/btyacc/btyacc_calc1.output create mode 100644 contrib/byacc/test/btyacc/btyacc_calc1.tab.c create mode 100644 contrib/byacc/test/btyacc/btyacc_calc1.tab.h create mode 100644 contrib/byacc/test/btyacc/btyacc_demo.error create mode 100644 contrib/byacc/test/btyacc/btyacc_demo.output create mode 100644 contrib/byacc/test/btyacc/btyacc_demo.tab.c create mode 100644 contrib/byacc/test/btyacc/btyacc_demo.tab.h rename contrib/byacc/test/{pure_error.tab.h => btyacc/calc.error} (100%) create mode 100644 contrib/byacc/test/btyacc/calc.output create mode 100644 contrib/byacc/test/btyacc/calc.tab.c create mode 100644 contrib/byacc/test/btyacc/calc.tab.h create mode 100644 contrib/byacc/test/btyacc/calc1.error create mode 100644 contrib/byacc/test/btyacc/calc1.output create mode 100644 contrib/byacc/test/btyacc/calc1.tab.c create mode 100644 contrib/byacc/test/btyacc/calc1.tab.h create mode 100644 contrib/byacc/test/btyacc/calc2.error create mode 100644 contrib/byacc/test/btyacc/calc2.output create mode 100644 contrib/byacc/test/btyacc/calc2.tab.c create mode 100644 contrib/byacc/test/btyacc/calc2.tab.h create mode 100644 contrib/byacc/test/btyacc/calc3.error create mode 100644 contrib/byacc/test/btyacc/calc3.output create mode 100644 contrib/byacc/test/btyacc/calc3.tab.c create mode 100644 contrib/byacc/test/btyacc/calc3.tab.h create mode 100644 contrib/byacc/test/btyacc/code_calc.code.c create mode 100644 contrib/byacc/test/btyacc/code_calc.error create mode 100644 contrib/byacc/test/btyacc/code_calc.output create mode 100644 contrib/byacc/test/btyacc/code_calc.tab.c create mode 100644 contrib/byacc/test/btyacc/code_calc.tab.h create mode 100644 contrib/byacc/test/btyacc/code_debug.c create mode 100644 contrib/byacc/test/btyacc/code_debug.error create mode 100644 contrib/byacc/test/btyacc/code_debug.h create mode 100644 contrib/byacc/test/btyacc/code_debug.i create mode 100644 contrib/byacc/test/btyacc/code_debug.output create mode 100644 contrib/byacc/test/btyacc/code_error.code.c create mode 100644 contrib/byacc/test/btyacc/code_error.error create mode 100644 contrib/byacc/test/btyacc/code_error.output create mode 100644 contrib/byacc/test/btyacc/code_error.tab.c create mode 100644 contrib/byacc/test/btyacc/code_error.tab.h create mode 100644 contrib/byacc/test/btyacc/empty.error create mode 100644 contrib/byacc/test/btyacc/empty.output create mode 100644 contrib/byacc/test/btyacc/empty.tab.c create mode 100644 contrib/byacc/test/btyacc/empty.tab.h create mode 100644 contrib/byacc/test/btyacc/err_inherit1.error create mode 100644 contrib/byacc/test/btyacc/err_inherit1.output create mode 100644 contrib/byacc/test/btyacc/err_inherit1.tab.c create mode 100644 contrib/byacc/test/btyacc/err_inherit1.tab.h create mode 100644 contrib/byacc/test/btyacc/err_inherit2.error create mode 100644 contrib/byacc/test/btyacc/err_inherit2.output create mode 100644 contrib/byacc/test/btyacc/err_inherit2.tab.c create mode 100644 contrib/byacc/test/btyacc/err_inherit2.tab.h create mode 100644 contrib/byacc/test/btyacc/err_inherit3.error create mode 100644 contrib/byacc/test/btyacc/err_inherit3.output create mode 100644 contrib/byacc/test/btyacc/err_inherit3.tab.c create mode 100644 contrib/byacc/test/btyacc/err_inherit3.tab.h create mode 100644 contrib/byacc/test/btyacc/err_inherit4.error create mode 100644 contrib/byacc/test/btyacc/err_inherit4.output create mode 100644 contrib/byacc/test/btyacc/err_inherit4.tab.c create mode 100644 contrib/byacc/test/btyacc/err_inherit4.tab.h create mode 100644 contrib/byacc/test/btyacc/err_inherit5.error create mode 100644 contrib/byacc/test/btyacc/err_inherit5.output create mode 100644 contrib/byacc/test/btyacc/err_inherit5.tab.c create mode 100644 contrib/byacc/test/btyacc/err_inherit5.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax1.error create mode 100644 contrib/byacc/test/btyacc/err_syntax1.output create mode 100644 contrib/byacc/test/btyacc/err_syntax1.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax1.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax10.error create mode 100644 contrib/byacc/test/btyacc/err_syntax10.output create mode 100644 contrib/byacc/test/btyacc/err_syntax10.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax10.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax11.error create mode 100644 contrib/byacc/test/btyacc/err_syntax11.output create mode 100644 contrib/byacc/test/btyacc/err_syntax11.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax11.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax12.error create mode 100644 contrib/byacc/test/btyacc/err_syntax12.output create mode 100644 contrib/byacc/test/btyacc/err_syntax12.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax12.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax13.error create mode 100644 contrib/byacc/test/btyacc/err_syntax13.output create mode 100644 contrib/byacc/test/btyacc/err_syntax13.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax13.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax14.error create mode 100644 contrib/byacc/test/btyacc/err_syntax14.output create mode 100644 contrib/byacc/test/btyacc/err_syntax14.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax14.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax15.error create mode 100644 contrib/byacc/test/btyacc/err_syntax15.output create mode 100644 contrib/byacc/test/btyacc/err_syntax15.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax15.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax16.error create mode 100644 contrib/byacc/test/btyacc/err_syntax16.output create mode 100644 contrib/byacc/test/btyacc/err_syntax16.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax16.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax17.error create mode 100644 contrib/byacc/test/btyacc/err_syntax17.output create mode 100644 contrib/byacc/test/btyacc/err_syntax17.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax17.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax18.error create mode 100644 contrib/byacc/test/btyacc/err_syntax18.output create mode 100644 contrib/byacc/test/btyacc/err_syntax18.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax18.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax19.error create mode 100644 contrib/byacc/test/btyacc/err_syntax19.output create mode 100644 contrib/byacc/test/btyacc/err_syntax19.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax19.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax2.error create mode 100644 contrib/byacc/test/btyacc/err_syntax2.output create mode 100644 contrib/byacc/test/btyacc/err_syntax2.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax2.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax20.error create mode 100644 contrib/byacc/test/btyacc/err_syntax20.output create mode 100644 contrib/byacc/test/btyacc/err_syntax20.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax20.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax21.error create mode 100644 contrib/byacc/test/btyacc/err_syntax21.output create mode 100644 contrib/byacc/test/btyacc/err_syntax21.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax21.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax22.error create mode 100644 contrib/byacc/test/btyacc/err_syntax22.output create mode 100644 contrib/byacc/test/btyacc/err_syntax22.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax22.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax23.error create mode 100644 contrib/byacc/test/btyacc/err_syntax23.output create mode 100644 contrib/byacc/test/btyacc/err_syntax23.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax23.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax24.error create mode 100644 contrib/byacc/test/btyacc/err_syntax24.output create mode 100644 contrib/byacc/test/btyacc/err_syntax24.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax24.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax25.error create mode 100644 contrib/byacc/test/btyacc/err_syntax25.output create mode 100644 contrib/byacc/test/btyacc/err_syntax25.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax25.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax26.error create mode 100644 contrib/byacc/test/btyacc/err_syntax26.output create mode 100644 contrib/byacc/test/btyacc/err_syntax26.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax26.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax27.error create mode 100644 contrib/byacc/test/btyacc/err_syntax27.output create mode 100644 contrib/byacc/test/btyacc/err_syntax27.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax27.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax3.error create mode 100644 contrib/byacc/test/btyacc/err_syntax3.output create mode 100644 contrib/byacc/test/btyacc/err_syntax3.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax3.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax4.error create mode 100644 contrib/byacc/test/btyacc/err_syntax4.output create mode 100644 contrib/byacc/test/btyacc/err_syntax4.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax4.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax5.error create mode 100644 contrib/byacc/test/btyacc/err_syntax5.output create mode 100644 contrib/byacc/test/btyacc/err_syntax5.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax5.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax6.error create mode 100644 contrib/byacc/test/btyacc/err_syntax6.output create mode 100644 contrib/byacc/test/btyacc/err_syntax6.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax6.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax7.error create mode 100644 contrib/byacc/test/btyacc/err_syntax7.output create mode 100644 contrib/byacc/test/btyacc/err_syntax7.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax7.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax7a.error create mode 100644 contrib/byacc/test/btyacc/err_syntax7a.output create mode 100644 contrib/byacc/test/btyacc/err_syntax7a.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax7a.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax7b.error create mode 100644 contrib/byacc/test/btyacc/err_syntax7b.output create mode 100644 contrib/byacc/test/btyacc/err_syntax7b.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax7b.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax8.error create mode 100644 contrib/byacc/test/btyacc/err_syntax8.output create mode 100644 contrib/byacc/test/btyacc/err_syntax8.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax8.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax8a.error create mode 100644 contrib/byacc/test/btyacc/err_syntax8a.output create mode 100644 contrib/byacc/test/btyacc/err_syntax8a.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax8a.tab.h create mode 100644 contrib/byacc/test/btyacc/err_syntax9.error create mode 100644 contrib/byacc/test/btyacc/err_syntax9.output create mode 100644 contrib/byacc/test/btyacc/err_syntax9.tab.c create mode 100644 contrib/byacc/test/btyacc/err_syntax9.tab.h create mode 100644 contrib/byacc/test/btyacc/error.error create mode 100644 contrib/byacc/test/btyacc/error.output create mode 100644 contrib/byacc/test/btyacc/error.tab.c create mode 100644 contrib/byacc/test/btyacc/error.tab.h create mode 100644 contrib/byacc/test/btyacc/grammar.dot create mode 100644 contrib/byacc/test/btyacc/grammar.error create mode 100644 contrib/byacc/test/btyacc/grammar.output create mode 100644 contrib/byacc/test/btyacc/grammar.tab.c create mode 100644 contrib/byacc/test/btyacc/grammar.tab.h create mode 100644 contrib/byacc/test/btyacc/help.error create mode 100644 contrib/byacc/test/btyacc/help.output create mode 100644 contrib/byacc/test/btyacc/inherit0.error create mode 100644 contrib/byacc/test/btyacc/inherit0.output create mode 100644 contrib/byacc/test/btyacc/inherit0.tab.c create mode 100644 contrib/byacc/test/btyacc/inherit0.tab.h create mode 100644 contrib/byacc/test/btyacc/inherit1.error create mode 100644 contrib/byacc/test/btyacc/inherit1.output create mode 100644 contrib/byacc/test/btyacc/inherit1.tab.c create mode 100644 contrib/byacc/test/btyacc/inherit1.tab.h create mode 100644 contrib/byacc/test/btyacc/inherit2.error create mode 100644 contrib/byacc/test/btyacc/inherit2.output create mode 100644 contrib/byacc/test/btyacc/inherit2.tab.c create mode 100644 contrib/byacc/test/btyacc/inherit2.tab.h create mode 100644 contrib/byacc/test/btyacc/no_b_opt.error create mode 100644 contrib/byacc/test/btyacc/no_b_opt.output create mode 100644 contrib/byacc/test/btyacc/no_b_opt1.error create mode 100644 contrib/byacc/test/btyacc/no_b_opt1.output create mode 100644 contrib/byacc/test/btyacc/no_code_c.error create mode 100644 contrib/byacc/test/btyacc/no_code_c.output create mode 100644 contrib/byacc/test/btyacc/no_defines.error create mode 100644 contrib/byacc/test/btyacc/no_defines.output create mode 100644 contrib/byacc/test/btyacc/no_graph.error create mode 100644 contrib/byacc/test/btyacc/no_graph.output create mode 100644 contrib/byacc/test/btyacc/no_include.error create mode 100644 contrib/byacc/test/btyacc/no_include.output create mode 100644 contrib/byacc/test/btyacc/no_opts.error create mode 100644 contrib/byacc/test/btyacc/no_opts.output create mode 100644 contrib/byacc/test/btyacc/no_output.error create mode 100644 contrib/byacc/test/btyacc/no_output.output create mode 100644 contrib/byacc/test/btyacc/no_output1.error create mode 100644 contrib/byacc/test/btyacc/no_output1.output create mode 100644 contrib/byacc/test/btyacc/no_output2.error create mode 100644 contrib/byacc/test/btyacc/no_output2.output create mode 100644 contrib/byacc/test/btyacc/no_p_opt.error create mode 100644 contrib/byacc/test/btyacc/no_p_opt.output create mode 100644 contrib/byacc/test/btyacc/no_p_opt1.error create mode 100644 contrib/byacc/test/btyacc/no_p_opt1.output create mode 100644 contrib/byacc/test/btyacc/no_verbose.error create mode 100644 contrib/byacc/test/btyacc/no_verbose.output create mode 100644 contrib/byacc/test/btyacc/nostdin.error create mode 100644 contrib/byacc/test/btyacc/nostdin.output create mode 100644 contrib/byacc/test/btyacc/ok_syntax1.error create mode 100644 contrib/byacc/test/btyacc/ok_syntax1.output create mode 100644 contrib/byacc/test/btyacc/ok_syntax1.tab.c create mode 100644 contrib/byacc/test/btyacc/ok_syntax1.tab.h create mode 100644 contrib/byacc/test/btyacc/pure_calc.error create mode 100644 contrib/byacc/test/btyacc/pure_calc.output create mode 100644 contrib/byacc/test/btyacc/pure_calc.tab.c create mode 100644 contrib/byacc/test/btyacc/pure_calc.tab.h create mode 100644 contrib/byacc/test/btyacc/pure_error.error create mode 100644 contrib/byacc/test/btyacc/pure_error.output create mode 100644 contrib/byacc/test/btyacc/pure_error.tab.c create mode 100644 contrib/byacc/test/btyacc/pure_error.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc-s.error create mode 100644 contrib/byacc/test/btyacc/quote_calc-s.output create mode 100644 contrib/byacc/test/btyacc/quote_calc-s.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc-s.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc.error create mode 100644 contrib/byacc/test/btyacc/quote_calc.output create mode 100644 contrib/byacc/test/btyacc/quote_calc.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc2-s.error create mode 100644 contrib/byacc/test/btyacc/quote_calc2-s.output create mode 100644 contrib/byacc/test/btyacc/quote_calc2-s.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc2-s.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc2.error create mode 100644 contrib/byacc/test/btyacc/quote_calc2.output create mode 100644 contrib/byacc/test/btyacc/quote_calc2.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc2.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc3-s.error create mode 100644 contrib/byacc/test/btyacc/quote_calc3-s.output create mode 100644 contrib/byacc/test/btyacc/quote_calc3-s.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc3-s.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc3.error create mode 100644 contrib/byacc/test/btyacc/quote_calc3.output create mode 100644 contrib/byacc/test/btyacc/quote_calc3.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc3.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc4-s.error create mode 100644 contrib/byacc/test/btyacc/quote_calc4-s.output create mode 100644 contrib/byacc/test/btyacc/quote_calc4-s.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc4-s.tab.h create mode 100644 contrib/byacc/test/btyacc/quote_calc4.error create mode 100644 contrib/byacc/test/btyacc/quote_calc4.output create mode 100644 contrib/byacc/test/btyacc/quote_calc4.tab.c create mode 100644 contrib/byacc/test/btyacc/quote_calc4.tab.h create mode 100644 contrib/byacc/test/btyacc/rename_debug.c create mode 100644 contrib/byacc/test/btyacc/rename_debug.error create mode 100644 contrib/byacc/test/btyacc/rename_debug.h create mode 100644 contrib/byacc/test/btyacc/rename_debug.i create mode 100644 contrib/byacc/test/btyacc/rename_debug.output create mode 100644 contrib/byacc/test/btyacc/varsyntax_calc1.error create mode 100644 contrib/byacc/test/btyacc/varsyntax_calc1.output create mode 100644 contrib/byacc/test/btyacc/varsyntax_calc1.tab.c create mode 100644 contrib/byacc/test/btyacc/varsyntax_calc1.tab.h create mode 100644 contrib/byacc/test/btyacc_calc1.y create mode 100644 contrib/byacc/test/btyacc_demo.y create mode 100644 contrib/byacc/test/code_debug.y delete mode 100644 contrib/byacc/test/code_error.tab.c create mode 100644 contrib/byacc/test/empty.y create mode 100644 contrib/byacc/test/err_inherit1.y create mode 100644 contrib/byacc/test/err_inherit2.y create mode 100644 contrib/byacc/test/err_inherit3.y create mode 100644 contrib/byacc/test/err_inherit4.y create mode 100644 contrib/byacc/test/err_inherit5.y create mode 100644 contrib/byacc/test/err_syntax1.y create mode 100644 contrib/byacc/test/err_syntax10.y create mode 100644 contrib/byacc/test/err_syntax11.y create mode 100644 contrib/byacc/test/err_syntax12.y create mode 100644 contrib/byacc/test/err_syntax13.y create mode 100644 contrib/byacc/test/err_syntax14.y create mode 100644 contrib/byacc/test/err_syntax15.y create mode 100644 contrib/byacc/test/err_syntax16.y create mode 100644 contrib/byacc/test/err_syntax17.y create mode 100644 contrib/byacc/test/err_syntax18.y create mode 100644 contrib/byacc/test/err_syntax19.y create mode 100644 contrib/byacc/test/err_syntax2.y create mode 100644 contrib/byacc/test/err_syntax20.y create mode 100644 contrib/byacc/test/err_syntax21.y create mode 100644 contrib/byacc/test/err_syntax22.y create mode 100644 contrib/byacc/test/err_syntax23.y create mode 100644 contrib/byacc/test/err_syntax24.y create mode 100644 contrib/byacc/test/err_syntax25.y create mode 100644 contrib/byacc/test/err_syntax26.y create mode 100644 contrib/byacc/test/err_syntax27.y create mode 100644 contrib/byacc/test/err_syntax3.y create mode 100644 contrib/byacc/test/err_syntax4.y create mode 100644 contrib/byacc/test/err_syntax5.y create mode 100644 contrib/byacc/test/err_syntax6.y create mode 100644 contrib/byacc/test/err_syntax7.y create mode 100644 contrib/byacc/test/err_syntax7a.y create mode 100644 contrib/byacc/test/err_syntax7b.y create mode 100644 contrib/byacc/test/err_syntax8.y create mode 100644 contrib/byacc/test/err_syntax8a.y create mode 100644 contrib/byacc/test/err_syntax9.y delete mode 100644 contrib/byacc/test/ftp.output delete mode 100644 contrib/byacc/test/ftp.tab.c delete mode 100644 contrib/byacc/test/ftp.tab.h delete mode 100644 contrib/byacc/test/ftp.y create mode 100644 contrib/byacc/test/inherit0.y create mode 100644 contrib/byacc/test/inherit1.y create mode 100644 contrib/byacc/test/inherit2.y create mode 100644 contrib/byacc/test/ok_syntax1.y create mode 100644 contrib/byacc/test/varsyntax_calc1.y create mode 100644 contrib/byacc/test/yacc/big_b.error create mode 100644 contrib/byacc/test/yacc/big_b.output create mode 100644 contrib/byacc/test/yacc/big_l.error create mode 100644 contrib/byacc/test/yacc/big_l.output create mode 100644 contrib/byacc/test/yacc/calc.error rename contrib/byacc/test/{ => yacc}/calc.output (100%) rename contrib/byacc/test/{ => yacc}/calc.tab.c (87%) rename contrib/byacc/test/{ => yacc}/calc.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/calc1.error rename contrib/byacc/test/{ => yacc}/calc1.output (100%) rename contrib/byacc/test/{ => yacc}/calc1.tab.c (90%) rename contrib/byacc/test/{ => yacc}/calc1.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/calc2.error rename contrib/byacc/test/{ => yacc}/calc2.output (100%) rename contrib/byacc/test/{ => yacc}/calc2.tab.c (87%) rename contrib/byacc/test/{ => yacc}/calc2.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/calc3.error rename contrib/byacc/test/{ => yacc}/calc3.output (100%) rename contrib/byacc/test/{ => yacc}/calc3.tab.c (87%) rename contrib/byacc/test/{ => yacc}/calc3.tab.h (100%) rename contrib/byacc/test/{ => yacc}/code_calc.code.c (86%) create mode 100644 contrib/byacc/test/yacc/code_calc.error rename contrib/byacc/test/{ => yacc}/code_calc.output (100%) rename contrib/byacc/test/{ => yacc}/code_calc.tab.c (70%) rename contrib/byacc/test/{ => yacc}/code_calc.tab.h (100%) rename contrib/byacc/test/{ => yacc}/code_error.code.c (84%) create mode 100644 contrib/byacc/test/yacc/code_error.error rename contrib/byacc/test/{ => yacc}/code_error.output (100%) create mode 100644 contrib/byacc/test/yacc/code_error.tab.c create mode 100644 contrib/byacc/test/yacc/code_error.tab.h create mode 100644 contrib/byacc/test/yacc/empty.error create mode 100644 contrib/byacc/test/yacc/empty.output create mode 100644 contrib/byacc/test/yacc/empty.tab.c create mode 100644 contrib/byacc/test/yacc/empty.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax1.error create mode 100644 contrib/byacc/test/yacc/err_syntax1.output create mode 100644 contrib/byacc/test/yacc/err_syntax1.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax1.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax10.error create mode 100644 contrib/byacc/test/yacc/err_syntax10.output create mode 100644 contrib/byacc/test/yacc/err_syntax10.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax10.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax11.error create mode 100644 contrib/byacc/test/yacc/err_syntax11.output create mode 100644 contrib/byacc/test/yacc/err_syntax11.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax11.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax12.error create mode 100644 contrib/byacc/test/yacc/err_syntax12.output create mode 100644 contrib/byacc/test/yacc/err_syntax12.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax12.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax13.error create mode 100644 contrib/byacc/test/yacc/err_syntax13.output create mode 100644 contrib/byacc/test/yacc/err_syntax13.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax13.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax14.error create mode 100644 contrib/byacc/test/yacc/err_syntax14.output create mode 100644 contrib/byacc/test/yacc/err_syntax14.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax14.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax15.error create mode 100644 contrib/byacc/test/yacc/err_syntax15.output create mode 100644 contrib/byacc/test/yacc/err_syntax15.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax15.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax16.error create mode 100644 contrib/byacc/test/yacc/err_syntax16.output create mode 100644 contrib/byacc/test/yacc/err_syntax16.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax16.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax17.error create mode 100644 contrib/byacc/test/yacc/err_syntax17.output create mode 100644 contrib/byacc/test/yacc/err_syntax17.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax17.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax18.error create mode 100644 contrib/byacc/test/yacc/err_syntax18.output create mode 100644 contrib/byacc/test/yacc/err_syntax18.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax18.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax19.error create mode 100644 contrib/byacc/test/yacc/err_syntax19.output create mode 100644 contrib/byacc/test/yacc/err_syntax19.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax19.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax2.error create mode 100644 contrib/byacc/test/yacc/err_syntax2.output create mode 100644 contrib/byacc/test/yacc/err_syntax2.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax2.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax20.error create mode 100644 contrib/byacc/test/yacc/err_syntax20.output create mode 100644 contrib/byacc/test/yacc/err_syntax20.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax20.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax21.error create mode 100644 contrib/byacc/test/yacc/err_syntax21.output create mode 100644 contrib/byacc/test/yacc/err_syntax21.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax21.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax22.error create mode 100644 contrib/byacc/test/yacc/err_syntax22.output create mode 100644 contrib/byacc/test/yacc/err_syntax22.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax22.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax23.error create mode 100644 contrib/byacc/test/yacc/err_syntax23.output create mode 100644 contrib/byacc/test/yacc/err_syntax23.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax23.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax24.error create mode 100644 contrib/byacc/test/yacc/err_syntax24.output create mode 100644 contrib/byacc/test/yacc/err_syntax24.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax24.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax25.error create mode 100644 contrib/byacc/test/yacc/err_syntax25.output create mode 100644 contrib/byacc/test/yacc/err_syntax25.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax25.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax26.error create mode 100644 contrib/byacc/test/yacc/err_syntax26.output create mode 100644 contrib/byacc/test/yacc/err_syntax26.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax26.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax27.error create mode 100644 contrib/byacc/test/yacc/err_syntax27.output create mode 100644 contrib/byacc/test/yacc/err_syntax27.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax27.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax3.error create mode 100644 contrib/byacc/test/yacc/err_syntax3.output create mode 100644 contrib/byacc/test/yacc/err_syntax3.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax3.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax4.error create mode 100644 contrib/byacc/test/yacc/err_syntax4.output create mode 100644 contrib/byacc/test/yacc/err_syntax4.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax4.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax5.error create mode 100644 contrib/byacc/test/yacc/err_syntax5.output create mode 100644 contrib/byacc/test/yacc/err_syntax5.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax5.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax6.error create mode 100644 contrib/byacc/test/yacc/err_syntax6.output create mode 100644 contrib/byacc/test/yacc/err_syntax6.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax6.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax7.error create mode 100644 contrib/byacc/test/yacc/err_syntax7.output create mode 100644 contrib/byacc/test/yacc/err_syntax7.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax7.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax7a.error create mode 100644 contrib/byacc/test/yacc/err_syntax7a.output create mode 100644 contrib/byacc/test/yacc/err_syntax7a.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax7a.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax7b.error create mode 100644 contrib/byacc/test/yacc/err_syntax7b.output create mode 100644 contrib/byacc/test/yacc/err_syntax7b.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax7b.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax8.error create mode 100644 contrib/byacc/test/yacc/err_syntax8.output create mode 100644 contrib/byacc/test/yacc/err_syntax8.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax8.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax8a.error create mode 100644 contrib/byacc/test/yacc/err_syntax8a.output create mode 100644 contrib/byacc/test/yacc/err_syntax8a.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax8a.tab.h create mode 100644 contrib/byacc/test/yacc/err_syntax9.error create mode 100644 contrib/byacc/test/yacc/err_syntax9.output create mode 100644 contrib/byacc/test/yacc/err_syntax9.tab.c create mode 100644 contrib/byacc/test/yacc/err_syntax9.tab.h create mode 100644 contrib/byacc/test/yacc/error.error rename contrib/byacc/test/{ => yacc}/error.output (100%) rename contrib/byacc/test/{ => yacc}/error.tab.c (77%) create mode 100644 contrib/byacc/test/yacc/error.tab.h create mode 100644 contrib/byacc/test/yacc/grammar.dot create mode 100644 contrib/byacc/test/yacc/grammar.error rename contrib/byacc/test/{ => yacc}/grammar.output (100%) rename contrib/byacc/test/{ => yacc}/grammar.tab.c (96%) rename contrib/byacc/test/{ => yacc}/grammar.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/help.error create mode 100644 contrib/byacc/test/yacc/help.output create mode 100644 contrib/byacc/test/yacc/no_b_opt.error create mode 100644 contrib/byacc/test/yacc/no_b_opt.output create mode 100644 contrib/byacc/test/yacc/no_b_opt1.error create mode 100644 contrib/byacc/test/yacc/no_b_opt1.output create mode 100644 contrib/byacc/test/yacc/no_code_c.error create mode 100644 contrib/byacc/test/yacc/no_code_c.output create mode 100644 contrib/byacc/test/yacc/no_defines.error create mode 100644 contrib/byacc/test/yacc/no_defines.output create mode 100644 contrib/byacc/test/yacc/no_graph.error create mode 100644 contrib/byacc/test/yacc/no_graph.output create mode 100644 contrib/byacc/test/yacc/no_include.error create mode 100644 contrib/byacc/test/yacc/no_include.output create mode 100644 contrib/byacc/test/yacc/no_opts.error create mode 100644 contrib/byacc/test/yacc/no_opts.output create mode 100644 contrib/byacc/test/yacc/no_output.error create mode 100644 contrib/byacc/test/yacc/no_output.output create mode 100644 contrib/byacc/test/yacc/no_output1.error create mode 100644 contrib/byacc/test/yacc/no_output1.output create mode 100644 contrib/byacc/test/yacc/no_output2.error create mode 100644 contrib/byacc/test/yacc/no_output2.output create mode 100644 contrib/byacc/test/yacc/no_p_opt.error create mode 100644 contrib/byacc/test/yacc/no_p_opt.output create mode 100644 contrib/byacc/test/yacc/no_p_opt1.error create mode 100644 contrib/byacc/test/yacc/no_p_opt1.output create mode 100644 contrib/byacc/test/yacc/no_verbose.error create mode 100644 contrib/byacc/test/yacc/no_verbose.output create mode 100644 contrib/byacc/test/yacc/nostdin.error create mode 100644 contrib/byacc/test/yacc/nostdin.output create mode 100644 contrib/byacc/test/yacc/ok_syntax1.error create mode 100644 contrib/byacc/test/yacc/ok_syntax1.output create mode 100644 contrib/byacc/test/yacc/ok_syntax1.tab.c create mode 100644 contrib/byacc/test/yacc/ok_syntax1.tab.h create mode 100644 contrib/byacc/test/yacc/pure_calc.error rename contrib/byacc/test/{ => yacc}/pure_calc.output (100%) rename contrib/byacc/test/{ => yacc}/pure_calc.tab.c (87%) rename contrib/byacc/test/{ => yacc}/pure_calc.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/pure_error.error rename contrib/byacc/test/{ => yacc}/pure_error.output (100%) rename contrib/byacc/test/{ => yacc}/pure_error.tab.c (78%) create mode 100644 contrib/byacc/test/yacc/pure_error.tab.h create mode 100644 contrib/byacc/test/yacc/quote_calc-s.error rename contrib/byacc/test/{ => yacc}/quote_calc-s.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc-s.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc-s.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/quote_calc.error rename contrib/byacc/test/{ => yacc}/quote_calc.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/quote_calc2-s.error rename contrib/byacc/test/{ => yacc}/quote_calc2-s.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc2-s.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc2-s.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/quote_calc2.error rename contrib/byacc/test/{ => yacc}/quote_calc2.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc2.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc2.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/quote_calc3-s.error rename contrib/byacc/test/{ => yacc}/quote_calc3-s.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc3-s.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc3-s.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/quote_calc3.error rename contrib/byacc/test/{ => yacc}/quote_calc3.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc3.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc3.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/quote_calc4-s.error rename contrib/byacc/test/{ => yacc}/quote_calc4-s.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc4-s.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc4-s.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/quote_calc4.error rename contrib/byacc/test/{ => yacc}/quote_calc4.output (100%) rename contrib/byacc/test/{ => yacc}/quote_calc4.tab.c (88%) rename contrib/byacc/test/{ => yacc}/quote_calc4.tab.h (100%) create mode 100644 contrib/byacc/test/yacc/rename_debug.c create mode 100644 contrib/byacc/test/yacc/rename_debug.error create mode 100644 contrib/byacc/test/yacc/rename_debug.h create mode 100644 contrib/byacc/test/yacc/rename_debug.i create mode 100644 contrib/byacc/test/yacc/rename_debug.output create mode 100644 contrib/byacc/test/yacc/varsyntax_calc1.error create mode 100644 contrib/byacc/test/yacc/varsyntax_calc1.output create mode 100644 contrib/byacc/test/yacc/varsyntax_calc1.tab.c create mode 100644 contrib/byacc/test/yacc/varsyntax_calc1.tab.h rename contrib/byacc/{skeleton.c => yaccpar.c} (83%) create mode 100644 contrib/byacc/yaccpar.skel diff --git a/contrib/byacc/CHANGES b/contrib/byacc/CHANGES index c00f95999..57a6c7f3e 100644 --- a/contrib/byacc/CHANGES +++ b/contrib/byacc/CHANGES @@ -1,3 +1,767 @@ +2014-04-22 Thomas E. Dickey + + * mstring.c: + use vsnprintf() to ensure that msprintf's buffer is large enough. + + * main.c, defs.h: add mstring_leaks() + + * configure: regen + + * output.c: fix a complementary warning + + * mstring.c: introduce vsnprintf + + * configure.in, config_h.in: add check for vsnprintf + + * output.c: quiet a type-conversion warning + + * mstring.c: fix a potential memory leak on ENOMEM + quiet a couple of type-conversion warnings + + * defs.h: add/use GCC_PRINTFLIKE for msprintf() + +2014-04-22 Tom.Shields + + * README.BTYACC: + drop "NOTES-btyacc-Changes" and "NOTES-btyacc-Disposition", merging relevant + content into README.BTYACC + +2014-04-22 Thomas E. Dickey + + * package/pkgsrc/Makefile, VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec: + bump + +2014-04-19 Thomas E. Dickey + + * config.sub: 2014-04-03 + + * config.guess: 2014-03-23 + +2014-04-09 Rick.Spates + + * main.c, defs.h: patch to allow DEBUG build with WIN32 system + +2014-04-09 Thomas E. Dickey + + * output.c, reader.c: gcc warnings + + * reader.c: fix const-cast warnings + + * test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/code_error.tab.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/error.tab.c, test/btyacc/rename_debug.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.tab.c, output.c: + fix a few clang --analyze warnings; one was a case where output_ctable emitted + an empty table (which should be an error). + + * reader.c: appease clang --analyze + + * defs.h: mark two functions as no-return. + + * package/debian/changelog: reason for release + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * makefile.in: use $LINT_OPTS from environment via configure script + + * test/btyacc/ok_syntax1.output, test/btyacc/ok_syntax1.tab.c, test/yacc/ok_syntax1.tab.c, test/ok_syntax1.y, test/yacc/ok_syntax1.output: + tweaks to make generated files from ok_syntax1.y compile with check_make rule + + * test/btyacc/rename_debug.c, test/btyacc/rename_debug.error, test/btyacc/rename_debug.h, test/btyacc/rename_debug.i, test/btyacc/rename_debug.output, test/yacc/rename_debug.c: + reference output for testing + + * test/run_test.sh: + retain the renaming done for code_debug.y so that check_make will work. + + * test/yacc/rename_debug.error, test/yacc/rename_debug.h, test/yacc/rename_debug.i, test/yacc/rename_debug.output: + reference output for testing + + * test/btyacc/ok_syntax1.error: RCS_BASE + + * test/yacc/quote_calc4-s.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/ok_syntax1.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, yaccpar.c: + regen + + * yacc.1: + clarify relationship of btyacc features to default configuration. + +2014-04-08 Thomas E. Dickey + + * test/yacc/ok_syntax1.output, test/yacc/ok_syntax1.tab.c, test/yacc/ok_syntax1.tab.h, test/btyacc/ok_syntax1.output, test/btyacc/ok_syntax1.tab.c, test/btyacc/ok_syntax1.tab.h: + reference output for testing + + * test/ok_syntax1.y: RCS_BASE + + * test/yacc/ok_syntax1.error: reference output for testing + + * test/yacc/big_b.error, test/yacc/big_b.output, test/yacc/big_l.error, test/yacc/big_l.output, test/btyacc/big_b.error, test/btyacc/big_b.output, test/btyacc/big_l.error, test/btyacc/big_l.output, test/run_test.sh: + exercise -L/-B options + + * test/yacc/code_debug.c, test/btyacc/code_debug.c, test/yacc/err_syntax15.tab.c, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax17.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax19.tab.c, test/yacc/err_syntax2.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax21.tab.c, test/yacc/err_syntax22.tab.c, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax24.tab.c, test/yacc/err_syntax25.tab.c, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax27.tab.c, test/yacc/err_syntax3.tab.c, test/yacc/err_syntax4.tab.c, test/yacc/err_syntax5.tab.c, test/yacc/err_syntax6.tab.c, test/yacc/err_syntax7.tab.c, test/yacc/err_syntax7a.tab.c, test/yacc/err_syntax7b.tab.c, test/yacc/err_syntax8.tab.c, test/yacc/err_syntax8a.tab.c, test/yacc/err_syntax9.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax1.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax13.tab.c, test/yacc/err_syntax14.tab.c, test/btyacc/err_syntax13.tab.c, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax2.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax24.tab.c, test/btyacc/err_syntax25.tab.c, test/btyacc/err_syntax26.tab.c, test/btyacc/err_syntax27.tab.c, test/btyacc/err_syntax3.tab.c, test/btyacc/err_syntax4.tab.c, test/btyacc/err_syntax5.tab.c, test/btyacc/err_syntax6.tab.c, test/btyacc/err_syntax7.tab.c, test/btyacc/err_syntax7a.tab.c, test/btyacc/err_syntax7b.tab.c, test/btyacc/err_syntax8.tab.c, test/btyacc/err_syntax8a.tab.c, test/btyacc/err_syntax9.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit5.tab.c, test/btyacc/err_syntax1.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/run_test.sh, test/yacc/no_b_opt1.output: + use a better renaming of the YYPATCH definition (none of the test-cases rely + upon it, but redefinition in the "make check_make" rule is a problem). + + * test/btyacc/err_syntax1.tab.c, test/btyacc/err_syntax13.tab.c, test/btyacc/err_syntax2.tab.c, test/btyacc/err_syntax25.tab.c, test/btyacc/err_syntax26.tab.c, test/btyacc/err_syntax27.tab.c, test/btyacc/err_syntax3.tab.c, test/btyacc/err_syntax4.tab.c, test/btyacc/err_syntax5.tab.c, test/btyacc/err_syntax6.tab.c, test/btyacc/err_syntax7.tab.c, test/btyacc/err_syntax7a.tab.c, test/btyacc/err_syntax7b.tab.c, test/btyacc/err_syntax8.tab.c, test/btyacc/err_syntax8a.tab.c, test/btyacc/err_syntax9.tab.c, test/btyacc/varsyntax_calc1.tab.c: + undid temporary reordering in reader() by Tom Shields to align with byacc outputs + + * test/run_test.sh: remove a repeated test-case + + * mstring.c: minor reformatting to make coverage analysis simpler + +2014-04-07 Thomas E. Dickey + + * test/run_test.sh: tidy + + * test/yacc/help.error, test/yacc/help.output, test/yacc/no_b_opt.error, test/yacc/no_b_opt.output, test/yacc/no_b_opt1.error, test/yacc/no_b_opt1.output, test/yacc/no_code_c.error, test/yacc/no_code_c.output, test/yacc/no_defines.error, test/yacc/no_defines.output, test/yacc/no_graph.error, test/yacc/no_graph.output, test/yacc/no_include.error, test/yacc/no_include.output, test/yacc/no_opts.error, test/yacc/no_opts.output, test/yacc/no_output.error, test/yacc/no_output.output, test/yacc/no_output1.error, test/yacc/no_output1.output, test/yacc/no_output2.error, test/yacc/no_output2.output, test/yacc/no_p_opt.error, test/yacc/no_p_opt.output, test/yacc/no_p_opt1.error, test/yacc/no_p_opt1.output, test/yacc/no_verbose.error, test/yacc/no_verbose.output, test/yacc/nostdin.error, test/yacc/nostdin.output, test/yacc/test-no_b_opt1.output: + reference output for testing + + * test/run_test.sh: + add special checks for flags which depend on writable/existing files + + * test/btyacc/no_b_opt1.output, test/btyacc/no_p_opt1.output, test/btyacc/no_b_opt.error, test/btyacc/no_b_opt.output, test/btyacc/no_b_opt1.error, test/btyacc/no_code_c.output, test/btyacc/no_p_opt.error, test/btyacc/no_p_opt.output, test/btyacc/no_p_opt1.error, test/btyacc/no_output2.output, test/btyacc/no_code_c.error, test/btyacc/no_output2.error, test/btyacc/no_include.error, test/btyacc/no_include.output, test/btyacc/no_defines.output, test/btyacc/no_defines.error, test/btyacc/no_verbose.output, test/btyacc/no_graph.output, test/btyacc/no_graph.error, test/btyacc/no_opts.error, test/btyacc/no_opts.output, test/btyacc/no_verbose.error, test/btyacc/nostdin.error, test/btyacc/nostdin.output, test/btyacc/no_output.error, test/btyacc/no_output.output, test/btyacc/no_output1.error, test/btyacc/no_output1.output: + reference output for testing + + * main.c: + change CREATE_FILE_NAMES() to use local function rather than inline code, + to simplify coverage analysis. + + * test/btyacc/err_syntax27.error, test/btyacc/err_syntax27.output, test/btyacc/err_syntax27.tab.c, test/btyacc/err_syntax27.tab.h, test/btyacc/help.error, test/btyacc/help.output, test/yacc/err_syntax27.error, test/yacc/err_syntax27.output, test/yacc/err_syntax27.tab.c, test/yacc/err_syntax27.tab.h: + reference output for testing + + * test/err_syntax27.y: testcase for missing_brace() + + * error.c: ifdef'd non-btyacc function + + * lr0.c: ifdef'd debug-code + + * yaccpar.skel: use YYINT's to replace short's as in btyaccpar.skel + + * test/btyacc/code_debug.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax24.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit5.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_debug.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, output.c, test/yacc/err_syntax1.tab.c, test/yacc/err_syntax13.tab.c, test/yacc/err_syntax14.tab.c, test/yacc/err_syntax15.tab.c, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax17.tab.c, test/yacc/err_syntax19.tab.c, test/yacc/err_syntax2.tab.c, test/yacc/err_syntax21.tab.c, test/yacc/err_syntax22.tab.c, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax24.tab.c, test/yacc/err_syntax25.tab.c, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax3.tab.c, test/yacc/err_syntax4.tab.c, test/yacc/err_syntax5.tab.c, test/yacc/err_syntax6.tab.c, test/yacc/err_syntax7.tab.c, test/yacc/err_syntax7a.tab.c, test/yacc/err_syntax7b.tab.c, test/yacc/err_syntax8.tab.c, test/yacc/err_syntax8a.tab.c, test/yacc/err_syntax9.tab.c, test/run_test.sh: + 2010/11/26 simplification of output.c using putc_code() and putl_code() + omitted an adjustment of the #line value used for code-file. Fix that. + Also, amend 2005/05/04 change to run_test.sh to retain a dummy line for + YYPATCH #define's to make test-outputs easier to compare #line's (report + by Tom Shields) + +2014-04-06 Thomas E. Dickey + + * reader.c: fix for valgrind + (the calloc's are intentional - valgrind reported use of uninitialized memory) + + * lr0.c, output.c: fix for valgrind + + * test/btyacc/code_debug.c, test/btyacc/code_debug.error, test/btyacc/code_debug.h, test/btyacc/code_debug.i, test/btyacc/code_debug.output: + RCS_BASE + + * test/yacc/code_debug.c, test/yacc/code_debug.h: + exercise the -i option + + * test/yacc/code_debug.i: reference output for testing + + * test/run_test.sh: exercise the -i option + + * test/yacc/code_debug.c: reference output for testing + + * test/run_test.sh: exercise the "-o" option + + * test/yacc/code_debug.error, test/yacc/code_debug.h, test/yacc/code_debug.output: + reference output for testing + + * output.c: don't call exit() without giving a chance to cleanup. + + * mstring.c: ifdef'd functions not used in byacc + + * btyaccpar.c: generated from btyaccpar.skel + + * yaccpar.c: generated from yaccpar.skel + + * skel2c: + change the generated-by comment to show which version of this script (and + which version of the given skeleton file) were used to produce the C-file. + + * configure: regen + + * makefile.in: + add rules to generate byacc and btyacc parser skeleton files independently + + * aclocal.m4: CF_PROG_AWK - add to byacc's configure script + CF_INTEL_COMPILER + cleanup the -no-gcc option which was leftover from testing - prcs does + not build with this option. + CF_MAKE_DOCS + protect $2 from substitution, for luit's "$(manext)" + CF_XOPEN_SOURCE + for Solaris (tested with gcc/g++ 3.4.3 on Solaris 10 and gcc/g++ 4.5.2 + on Solaris 11), suppress the followup check for defining _XOPEN_SOURCE + because it is not needed, as well as because g++ 4.7.3 (no package, + used in Sage for Solaris 10) has some unspecified header breakage which + is triggered by the duplicate definition. + + * configure.in: + modify so skeleton-source is determined by configure options rather than by + having developer rename yaccpar.skel.old to yaccpar.skel + + * descrip.mms: rename skeleton + + * vmsbuild.com: + fwiw, renamed the skeleton for consistency with makefile + + * skel2c, skeleton.c: resync skeleton and its generating files + + * yaccpar.skel: + renamed yaccpar.skel.old to yaccpar.skel, to allow using makefile suffix rules + + * yaccpar.skel.old: resync skeleton and its generating files + + * test/run_make.sh: improve cleanup after error recovery + + * test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, output.c, skeleton.c, defs.h: + use improvement from Tom Shield's btyacc changes, getting rid of special cases for generating two yyerror calls in skeleton + + * output.c: simplify output_yyerror_decl() + + * test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.tab.c, test/yacc/code_error.tab.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, output.c: + add second "const" to string-table declarations, from Tom Shield's btyacc changes + + * test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c: + discard unnecessary call on write_code_lineno() from Tom Shield's changes + + * test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_calc.tab.c, test/yacc/code_error.code.c, test/yacc/code_error.tab.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax20.tab.c, output.c: + use YYINT typedef from Tom Shield's btyacc changes to replace explicit "short" + + * test/yacc/code_calc.code.c, test/yacc/code_error.code.c, output.c: + use fix from Tom Shield's btyacc changes: remove redundant extern-declaration for YYPARSE_DECL() + + * test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c: + discard unnecessary call on write_code_lineno() from Tom Shield's changes + + * output.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/code_calc.tab.c, test/yacc/code_error.tab.c: + use fix from Tom Shield's btyacc changes: prefix-definitions went to the + output (.tab.c) file in a case where they should have gone to the code + (.code.c) file. Remove now-redundant call to output_prefix(). + + * main.c: do the same for help-message + + * main.c: use OUTPUT_SUFFIX symbol in an overlooked case + + * test/run_make.sh: + modify to avoid use of VPATH, which has no standard implementation + +2014-04-05 Thomas E. Dickey + + * test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c: + discard a change which merged CountLines() with explicit comparisons against + code_file because that adds extra to the #line values + + * test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/calc.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/error.tab.c, output.c: + add Tom Shield's change to allow definition of YYSTYPE_IS_DECLARED symbol to + override fallback typedef for YYSTYPE when that symbol is undefined + + * test/btyacc/error.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c: + minor tweak to coding style - use parenthesis for "defined" operator's parameter + + * test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c: + regen to make YYMAXTOKEN and YYUNDFTOKEN adjacent + + * test/yacc/err_syntax20.tab.c, test/yacc/grammar.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_calc.tab.c, test/yacc/code_error.code.c, test/yacc/code_error.tab.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c: + regen after adding the YYUNDFTOKEN symbol + + * output.c: + integrate Tom Shield's btyacc changes which introduce the YYUNDFTOKEN symbol + (I changed order of output to keep this adjacent to YYMAXTOKEN) + + * reader.c: + merge all but one small change from Tom Shield's btyacc changes - that + changes the order of code-file in the tests. + + * test/btyacc/btyacc_demo.tab.c: regen + + * test/btyacc_demo.y: fix prototypes + +2014-04-04 Thomas E. Dickey + + * reader.c, defs.h, main.c: + more merging of Tom Shield's btyacc changes. In the merge, I moved the + symbol_pval inside the btyacc ifdef's and added some more btyacc ifdefs + +2014-04-03 Thomas E. Dickey + + * reader.c: + merge-in 3/4 of btyacc's changes, deferring those which change test-outputs. + Tom Shield's changes split-out copy_string() and copy_comment() functions + to simplify some logic, as well as adding btyacc-only chunks + + * makefile.in: build mstring.o, needed for changes in reader.c + + * output.c: + merge-in all of btyacc's changes which do not change byacc's test-output. + Some of the merge uses ifdef-changes which I applied to ongoing resync, + e.g., the introduction of PER_STATE. + +2014-04-02 Thomas E. Dickey + + * test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c: regen + + * output.c: fix typo + + * output.c, reader.c: + merge in some chunks of reader and output files which do not affect byacc tests + + * test/yacc/calc2.tab.c, test/yacc/calc3.tab.c: regen + + * test/yacc/err_syntax6.tab.c, test/yacc/err_syntax7.tab.c, test/yacc/err_syntax7a.tab.c, test/yacc/err_syntax7b.tab.c, test/yacc/err_syntax8.tab.c, test/yacc/err_syntax8a.tab.c, test/yacc/err_syntax9.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax1.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax13.tab.c, test/yacc/err_syntax14.tab.c, test/yacc/err_syntax15.tab.c, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax17.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax19.tab.c, test/yacc/err_syntax2.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax21.tab.c, test/yacc/err_syntax22.tab.c, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax24.tab.c, test/yacc/err_syntax25.tab.c, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax3.tab.c, test/yacc/err_syntax4.tab.c, test/yacc/err_syntax5.tab.c, skeleton.c: + incorporate YYENOMEM and YYEOF symbols from btyacc + + * output.c: merge chunk from btyacc changes for header-guards + + * btyaccpar.skel: RCS_BASE + + * yaccpar.skel: comment-out yysccsid[], for FreeBSD build-issues + remove GCC_UNUSED to reduce name-pollution as well as being simpler + + * main.c: + move a btyacc symbol outside ifdef to work around current state of merge + + * defs.h: + add USE_HEADER_GUARDS to defer whether to modify byacc's header-output + + * test/run_make.sh: + do not try to compile files used for testing syntax-errors, since they are + likely to be incomplete + +2014-04-02 Tom.Shields + + * main.c: changes for btyacc + +2014-04-01 Thomas E. Dickey + + * reader.c: + integrate change by Tom Shields to use bsearch rather than successive + calls to matchec() + + * defs.h: typedef __compar_fn_t is unnecessary + + * test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c: + omit the GCC_UNUSED, as noted by Tom Shields not really essential + +2014-04-01 Tom.Shields + + * verbose.c: changes for btyacc, ifdef'd + +2014-04-01 Thomas E. Dickey + + * mkpar.c: eliminate most of the ifdef's using macros + +2014-04-01 Tom.Shields + + * mkpar.c: merge btyacc changes (ifdef'd - no change to byacc) + + * error.c: + new functions used for reporting errors from the btyacc configuration + (I reordered some, and ifdef'd the new ones -TD) + +2014-03-31 Thomas E. Dickey + + * test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c: + omit the GCC_UNUSED, as noted by Tom Shields not really essential + + * test/btyacc/empty.tab.c, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit5.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax24.tab.c: + regen + +2014-03-29 Thomas E. Dickey + + * test/yacc/err_syntax22.tab.c, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax24.tab.c, test/yacc/err_syntax25.tab.c, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax3.tab.c, test/yacc/err_syntax4.tab.c, test/yacc/err_syntax5.tab.c, test/yacc/err_syntax6.tab.c, test/yacc/err_syntax7.tab.c, test/yacc/err_syntax7a.tab.c, test/yacc/err_syntax7b.tab.c, test/yacc/err_syntax8.tab.c, test/yacc/err_syntax8a.tab.c, test/yacc/err_syntax9.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax1.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax13.tab.c, test/yacc/err_syntax14.tab.c, test/yacc/err_syntax15.tab.c, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax17.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax19.tab.c, test/yacc/err_syntax2.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax21.tab.c, skeleton.c: + comment-out yysccsid in the banner because it produces unnecessary compiler + warnings. The suggested alternative (using #pragma ident) in the preceding + comment is also obsolete; remove that comment (request by Gleb Smirnoff). + + * test/run_test.sh: + for yacc, ignore the inherit testcases, since they are btyacc-specific + +2014-03-28 Thomas E. Dickey + + * test/yacc/varsyntax_calc1.error, test/yacc/varsyntax_calc1.output, test/yacc/varsyntax_calc1.tab.c, test/yacc/varsyntax_calc1.tab.h, test/yacc/err_inherit3.error, test/yacc/err_inherit3.output, test/yacc/err_inherit3.tab.c, test/yacc/err_inherit3.tab.h, test/yacc/err_inherit4.error, test/yacc/err_inherit4.output, test/yacc/err_inherit4.tab.c, test/yacc/err_inherit4.tab.h, test/yacc/err_inherit5.error, test/yacc/err_inherit5.output, test/yacc/err_inherit5.tab.c, test/yacc/err_inherit5.tab.h, test/yacc/inherit0.error, test/yacc/inherit0.output, test/yacc/inherit0.tab.c, test/yacc/inherit0.tab.h, test/yacc/inherit1.error, test/yacc/inherit1.output, test/yacc/inherit1.tab.c, test/yacc/inherit1.tab.h, test/yacc/inherit2.error, test/yacc/inherit2.output, test/yacc/inherit2.tab.c, test/yacc/inherit2.tab.h, test/yacc/empty.error, test/yacc/empty.output, test/yacc/empty.tab.c, test/yacc/empty.tab.h, test/yacc/err_inherit1.error, test/yacc/err_inherit1.output, test/yacc/err_inherit1.tab.c, test/yacc/err_inherit1.tab.h, test/yacc/err_inherit2.error, test/yacc/err_inherit2.output, test/yacc/err_inherit2.tab.c, test/yacc/err_inherit2.tab.h: + reference output for testing + + * test/run_lint.sh, test/run_make.sh, test/run_test.sh: + moving #define's out of makefile broke check for yacc vs btyacc (fix) + +2014-03-28 Tom.Shields + + * test/btyacc/btyacc_demo.tab.c, test/btyacc/err_inherit3.error, test/btyacc/err_inherit3.output, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit3.tab.h, test/btyacc/err_inherit2.error, test/btyacc/err_inherit2.output, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit2.tab.h, test/btyacc/err_inherit4.error, test/btyacc/err_inherit4.output, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit4.tab.h, test/btyacc/err_inherit5.error, test/btyacc/err_inherit5.output, test/btyacc/err_inherit5.tab.c, test/btyacc/err_inherit5.tab.h, test/btyacc/inherit0.error, test/btyacc/inherit0.output, test/btyacc/inherit0.tab.c, test/btyacc/inherit0.tab.h, test/btyacc/inherit1.error, test/btyacc/inherit1.output, test/btyacc/inherit1.tab.c, test/btyacc/inherit1.tab.h, test/btyacc/inherit2.error, test/btyacc/inherit2.output, test/btyacc/inherit2.tab.c, test/btyacc/inherit2.tab.h, test/btyacc/calc.error, test/btyacc/err_inherit1.error, test/btyacc/err_inherit1.output, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit1.tab.h: + reference output for testing + + * defs.h: new functions/variables for btyacc + (I reordered and ifdef'd -TD) + + * test/inherit0.y, test/inherit1.y: testcase for btyacc + +2014-03-27 Tom.Shields + + * test/err_inherit5.y, test/err_inherit4.y, test/err_inherit3.y, test/err_inherit2.y, test/err_inherit1.y, test/inherit2.y: + testcase for btyacc + +2014-03-25 Tom.Shields + + * symtab.c: extra initialization needed for btyacc + (I ifdef'd -TD) + + * yacc.1: document -L/-B features from btyacc + +2014-03-25 Thomas E. Dickey + + * yacc.1: typo + + * configure: regen + + * configure.in: + modified new options to act like those in my other configure-scripts, e.g., + showing what option is being tested, and the resulting value. Put the + definitions in config.h rather than in the makefile. + +2014-03-25 Tom.Shields + + * makefile.in: add/use LINTFLAGS variable + make all of the objects (not just skeleton) rebuild if makefile changes + modify check-rule to reflect updates to run_test.sh vs subdirectory + + * mstring.c: byacc-btyacc-20140323 + +2014-03-25 Thomas E. Dickey + + * test/btyacc/RCS, test/yacc/RCS: PERMIT FILE + + * config_h.in: updated with autoheader-252 + +2014-03-25 Tom.Shields + + * README.BTYACC: byacc-btyacc-20140323 + +2014-03-24 Tom.Shields + + * test/btyacc/err_syntax1.output, test/btyacc/err_syntax1.tab.c, test/btyacc/err_syntax1.tab.h, test/btyacc/err_syntax10.error, test/btyacc/err_syntax10.output, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax10.tab.h, test/btyacc/err_syntax11.error, test/btyacc/err_syntax11.output, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax11.tab.h, test/btyacc/err_syntax12.error, test/btyacc/err_syntax12.output, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax12.tab.h, test/btyacc/err_syntax13.error, test/btyacc/err_syntax13.output, test/btyacc/err_syntax13.tab.c, test/btyacc/err_syntax13.tab.h, test/btyacc/err_syntax14.error, test/btyacc/err_syntax14.output, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax14.tab.h, test/btyacc/err_syntax15.error, test/btyacc/err_syntax15.output, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax15.tab.h, test/btyacc/err_syntax16.error, test/btyacc/err_syntax16.output, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax16.tab.h, test/btyacc/err_syntax17.error, test/btyacc/err_syntax17.output, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax17.tab.h, test/btyacc/err_syntax18.error, test/btyacc/err_syntax18.output, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax18.tab.h, test/btyacc/err_syntax19.error, test/btyacc/err_syntax19.output, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax19.tab.h, test/btyacc/err_syntax2.output, test/btyacc/err_syntax2.tab.c, test/btyacc/err_syntax2.tab.h, test/btyacc/err_syntax20.error, test/btyacc/err_syntax20.output, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax20.tab.h, test/btyacc/err_syntax21.error, test/btyacc/err_syntax21.output, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax21.tab.h, test/btyacc/err_syntax22.error, test/btyacc/err_syntax22.output, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax22.tab.h, test/btyacc/err_syntax23.error, test/btyacc/err_syntax23.output, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax23.tab.h, test/btyacc/err_syntax24.error, test/btyacc/err_syntax24.output, test/btyacc/err_syntax24.tab.c, test/btyacc/err_syntax24.tab.h, test/btyacc/err_syntax25.error, test/btyacc/err_syntax25.output, test/btyacc/err_syntax25.tab.c, test/btyacc/err_syntax25.tab.h, test/btyacc/err_syntax26.error, test/btyacc/err_syntax26.output, test/btyacc/err_syntax26.tab.c, test/btyacc/err_syntax26.tab.h, test/btyacc/err_syntax3.output, test/btyacc/err_syntax3.tab.c, test/btyacc/err_syntax3.tab.h, test/btyacc/err_syntax4.output, test/btyacc/err_syntax4.tab.c, test/btyacc/err_syntax4.tab.h, test/btyacc/err_syntax5.output, test/btyacc/err_syntax5.tab.c, test/btyacc/err_syntax5.tab.h, test/btyacc/err_syntax6.output, test/btyacc/err_syntax6.tab.c, test/btyacc/err_syntax6.tab.h, test/btyacc/err_syntax7.output, test/btyacc/err_syntax7.tab.c, test/btyacc/err_syntax7.tab.h, test/btyacc/err_syntax7a.output, test/btyacc/err_syntax7a.tab.c, test/btyacc/err_syntax7a.tab.h, test/btyacc/err_syntax7b.output, test/btyacc/err_syntax7b.tab.c, test/btyacc/err_syntax7b.tab.h, test/btyacc/err_syntax8.output, test/btyacc/err_syntax8.tab.c, test/btyacc/err_syntax8.tab.h, test/btyacc/err_syntax8a.output, test/btyacc/err_syntax8a.tab.c, test/btyacc/err_syntax8a.tab.h, test/btyacc/err_syntax9.output, test/btyacc/err_syntax9.tab.c, test/btyacc/err_syntax9.tab.h: + reference output for testing + +2014-03-24 Thomas E. Dickey + + * defs.h: fix compiler warnings due to mputc() + +2014-03-23 Tom.Shields + + * test/btyacc_demo.y: testcase for btyacc + + * test/btyacc/varsyntax_calc1.error, test/btyacc/varsyntax_calc1.output, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/varsyntax_calc1.tab.h: + reference output for testing + + * test/varsyntax_calc1.y, test/btyacc_calc1.y: testcase for btyacc + +2014-03-23 Thomas E. Dickey + + * test/err_syntax26.error, test/err_syntax26.output, test/err_syntax26.tab.c, test/err_syntax26.tab.h, test/yacc/err_syntax26.error, test/yacc/err_syntax26.output, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax26.tab.h: + reference output for testing + + * test/err_syntax26.y: testcase for missing_brace() + + * test/err_syntax25.error, test/err_syntax25.output, test/err_syntax25.tab.c, test/err_syntax25.tab.h, test/yacc/err_syntax25.error, test/yacc/err_syntax25.output, test/yacc/err_syntax25.tab.c, test/yacc/err_syntax25.tab.h: + reference output for testing + + * test/err_syntax25.y: testcase for over_unionized() + + * test/err_syntax24.error, test/err_syntax24.output, test/err_syntax24.tab.c, test/err_syntax24.tab.h, test/yacc/err_syntax24.error, test/yacc/err_syntax24.output, test/yacc/err_syntax24.tab.c, test/yacc/err_syntax24.tab.h: + reference output for testing + + * test/err_syntax24.y: testcase for default_action_warning() + +2014-03-23 Tom.Shields + + * test/btyacc/quote_calc3-s.error, test/btyacc/quote_calc4-s.error, test/btyacc/quote_calc4.error, test/btyacc/grammar.dot, test/btyacc/grammar.error, test/btyacc/pure_calc.error, test/btyacc/pure_error.error, test/btyacc/quote_calc-s.error, test/btyacc/quote_calc.error, test/btyacc/quote_calc2-s.error, test/btyacc/quote_calc2.error, test/btyacc/quote_calc3.error, test/btyacc/err_syntax2.error, test/btyacc/err_syntax3.error, test/btyacc/err_syntax4.error, test/btyacc/err_syntax5.error, test/btyacc/err_syntax6.error, test/btyacc/err_syntax7.error, test/btyacc/err_syntax7a.error, test/btyacc/err_syntax7b.error, test/btyacc/err_syntax8.error, test/btyacc/err_syntax8a.error, test/btyacc/err_syntax9.error, test/btyacc/error.error, test/btyacc/calc1.error, test/btyacc/calc2.error, test/btyacc/calc3.error, test/btyacc/code_calc.error, test/btyacc/code_error.error, test/btyacc/empty.error, test/btyacc/err_syntax1.error, test/btyacc/btyacc_calc1.error, test/btyacc/btyacc_demo.error: + reference output for testing + +2014-03-23 Thomas E. Dickey + + * test/err_syntax23.error, test/err_syntax23.output, test/err_syntax23.tab.c, test/err_syntax23.tab.h, test/yacc/err_syntax23.error, test/yacc/err_syntax23.output, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax23.tab.h: + reference output for testing + + * test/err_syntax23.y: testcase for untyped_lhs() + +2014-03-23 Tom.Shields + + * test/run_test.sh: + move test-outputs into subdirectories to keep btyacc/yacc results separate + +2014-03-23 Thomas E. Dickey + + * test/err_syntax22.error, test/err_syntax22.output, test/err_syntax22.tab.c, test/err_syntax22.tab.h, test/yacc/err_syntax22.error, test/yacc/err_syntax22.output, test/yacc/err_syntax22.tab.c, test/yacc/err_syntax22.tab.h: + reference output for testing + + * test/err_syntax22.y: testcase for untyped_rhs() + + * test/err_syntax21.error, test/err_syntax21.output, test/err_syntax21.tab.c, test/err_syntax21.tab.h, test/yacc/err_syntax21.error, test/yacc/err_syntax21.output, test/yacc/err_syntax21.tab.c, test/yacc/err_syntax21.tab.h, test/err_syntax20.error, test/err_syntax20.output, test/err_syntax20.tab.c, test/err_syntax20.tab.h, test/yacc/err_syntax20.error, test/yacc/err_syntax20.output, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax20.tab.h: + reference output for testing + + * test/err_syntax20.y: testcase for undefined_symbol_warning() + + * test/err_syntax21.y: testcase for unknown_rhs() + + * test/err_syntax19.error, test/err_syntax19.output, test/err_syntax19.tab.c, test/err_syntax19.tab.h, test/yacc/err_syntax19.error, test/yacc/err_syntax19.output, test/yacc/err_syntax19.tab.c, test/yacc/err_syntax19.tab.h: + reference output for testing + + * test/err_syntax19.y: testcase for dollar_error() + + * test/err_syntax18.error, test/err_syntax18.output, test/err_syntax18.tab.c, test/err_syntax18.tab.h, test/yacc/err_syntax18.error, test/yacc/err_syntax18.output, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax18.tab.h: + reference output for testing + + * test/err_syntax18.y: testcase for dollar_warning() + + * test/err_syntax17.error, test/err_syntax17.output, test/err_syntax17.tab.c, test/err_syntax17.tab.h, test/yacc/err_syntax17.error, test/yacc/err_syntax17.output, test/yacc/err_syntax17.tab.c, test/yacc/err_syntax17.tab.h: + reference output for testing + + * test/err_syntax17.y: testcase for unterminated_action() + +2014-03-22 Thomas E. Dickey + + * test/err_syntax16.error, test/err_syntax16.output, test/err_syntax16.tab.c, test/err_syntax16.tab.h, test/yacc/err_syntax16.error, test/yacc/err_syntax16.output, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax16.tab.h: + reference output for testing + + * test/err_syntax16.y: testcase for terminal_lhs() + + * test/err_syntax15.error, test/err_syntax15.output, test/err_syntax15.tab.c, test/err_syntax15.tab.h, test/yacc/err_syntax15.error, test/yacc/err_syntax15.output, test/yacc/err_syntax15.tab.c, test/yacc/err_syntax15.tab.h: + reference output for testing + + * test/err_syntax15.y: testcase for no_grammar() + + * test/err_syntax14.error, test/err_syntax14.output, test/err_syntax14.tab.c, test/err_syntax14.tab.h, test/yacc/err_syntax14.error, test/yacc/err_syntax14.output, test/yacc/err_syntax14.tab.c, test/yacc/err_syntax14.tab.h: + reference output for testing + + * test/err_syntax14.y: + testcase for restarted_warning() and undefined_goal() + + * test/err_syntax13.error, test/err_syntax13.output, test/err_syntax13.tab.c, test/err_syntax13.tab.h, test/yacc/err_syntax13.error, test/yacc/err_syntax13.output, test/yacc/err_syntax13.tab.c, test/yacc/err_syntax13.tab.h: + reference output for testing + + * test/err_syntax13.y: testcase for terminal_start() + + * test/err_syntax12.error, test/err_syntax12.output, test/err_syntax12.tab.c, test/err_syntax12.tab.h, test/yacc/err_syntax12.error, test/yacc/err_syntax12.output, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax12.tab.h: + reference output for testing + + * test/err_syntax12.y: testcase for revalued_warning() + + * test/err_syntax11.error, test/err_syntax11.output, test/err_syntax11.tab.c, test/err_syntax11.tab.h, test/yacc/err_syntax11.error, test/yacc/err_syntax11.output, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax11.tab.h: + reference output for testing + + * test/err_syntax11.y: testcase for reprec_warning() + + * test/err_syntax10.error, test/err_syntax10.output, test/err_syntax10.tab.c, test/err_syntax10.tab.h, test/yacc/err_syntax10.error, test/yacc/err_syntax10.output, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax10.tab.h: + reference output for testing + + * test/err_syntax10.y: testcase for retyped_warning() + +2014-03-21 Thomas E. Dickey + + * test/err_syntax9.error, test/err_syntax9.output, test/err_syntax9.tab.c, test/err_syntax9.tab.h, test/yacc/err_syntax9.error, test/yacc/err_syntax9.output, test/yacc/err_syntax9.tab.c, test/yacc/err_syntax9.tab.h: + reference output for testing + + * test/err_syntax9.y: testcase for tokenized_start() + + * test/err_syntax8.error, test/err_syntax8.output, test/err_syntax8.tab.c, test/err_syntax8.tab.h, test/err_syntax8a.error, test/err_syntax8a.output, test/err_syntax8a.tab.c, test/err_syntax8a.tab.h, test/yacc/err_syntax8.error, test/yacc/err_syntax8.output, test/yacc/err_syntax8.tab.c, test/yacc/err_syntax8.tab.h, test/yacc/err_syntax8a.error, test/yacc/err_syntax8a.output, test/yacc/err_syntax8a.tab.c, test/yacc/err_syntax8a.tab.h: + reference output for testing + + * test/err_syntax8a.y, test/err_syntax8.y: testcase for used_reserved() + + * test/err_syntax7.error, test/err_syntax7.output, test/err_syntax7.tab.c, test/err_syntax7.tab.h, test/err_syntax7a.error, test/err_syntax7a.output, test/err_syntax7a.tab.c, test/err_syntax7a.tab.h, test/err_syntax7b.error, test/err_syntax7b.output, test/err_syntax7b.tab.c, test/err_syntax7b.tab.h, test/yacc/err_syntax7.error, test/yacc/err_syntax7.output, test/yacc/err_syntax7.tab.c, test/yacc/err_syntax7.tab.h, test/yacc/err_syntax7a.error, test/yacc/err_syntax7a.output, test/yacc/err_syntax7a.tab.c, test/yacc/err_syntax7a.tab.h, test/yacc/err_syntax7b.error, test/yacc/err_syntax7b.output, test/yacc/err_syntax7b.tab.c, test/yacc/err_syntax7b.tab.h: + reference output for testing + + * test/err_syntax7b.y, test/err_syntax7a.y, test/err_syntax7.y: + testcase for illegal_character() + + * test/err_syntax6.error, test/err_syntax6.output, test/err_syntax6.tab.c, test/err_syntax6.tab.h, test/yacc/err_syntax6.error, test/yacc/err_syntax6.output, test/yacc/err_syntax6.tab.c, test/yacc/err_syntax6.tab.h: + reference output for testing + + * test/err_syntax6.y: testcase for illegal_tag() + + * test/err_syntax5.error, test/err_syntax5.output, test/err_syntax5.tab.c, test/err_syntax5.tab.h, test/yacc/err_syntax5.error, test/yacc/err_syntax5.output, test/yacc/err_syntax5.tab.c, test/yacc/err_syntax5.tab.h: + reference output for testing + + * test/err_syntax5.y: testcase for unterminated_union() + + * test/err_syntax4.error, test/err_syntax4.output, test/err_syntax4.tab.c, test/err_syntax4.tab.h, test/yacc/err_syntax4.error, test/yacc/err_syntax4.output, test/yacc/err_syntax4.tab.c, test/yacc/err_syntax4.tab.h: + reference output for testing + + * test/err_syntax4.y: testcase for unterminated_text() + + * test/err_syntax3.error, test/err_syntax3.output, test/err_syntax3.tab.c, test/err_syntax3.tab.h, test/yacc/err_syntax3.error, test/yacc/err_syntax3.output, test/yacc/err_syntax3.tab.c, test/yacc/err_syntax3.tab.h: + reference output for testing + + * test/err_syntax3.y: testcase for unterminated_string() + + * test/err_syntax2.error, test/err_syntax2.output, test/err_syntax2.tab.c, test/err_syntax2.tab.h, test/yacc/err_syntax2.error, test/yacc/err_syntax2.output, test/yacc/err_syntax2.tab.c, test/yacc/err_syntax2.tab.h: + reference output for testing + + * test/err_syntax2.y: testcase for unterminated_comment() + + * test/err_syntax1.error, test/yacc/err_syntax1.error: + reference output for testing + + * test/err_syntax1.y: + test-case with syntax error (and nonprinting character) + + * test/calc.error, test/calc1.error, test/calc2.error, test/calc3.error, test/code_calc.error, test/code_error.error, test/err_syntax1.error, test/error.error, test/grammar.error, test/pure_calc.error, test/pure_error.error, test/quote_calc-s.error, test/quote_calc.error, test/quote_calc2-s.error, test/quote_calc2.error, test/quote_calc3-s.error, test/quote_calc3.error, test/quote_calc4-s.error, test/quote_calc4.error, test/yacc/calc.error, test/yacc/calc1.error, test/yacc/calc2.error, test/yacc/calc3.error, test/yacc/code_calc.error, test/yacc/code_error.error, test/yacc/error.error, test/yacc/grammar.error, test/yacc/pure_calc.error, test/yacc/pure_error.error, test/yacc/quote_calc-s.error, test/yacc/quote_calc.error, test/yacc/quote_calc2-s.error, test/yacc/quote_calc2.error, test/yacc/quote_calc3-s.error, test/yacc/quote_calc3.error, test/yacc/quote_calc4-s.error, test/yacc/quote_calc4.error: + reference output for testing + + * test/run_test.sh: + save stderr to reference files, to capture shift/reduce messages as well + as syntax-error messages + + * test/err_syntax1.output, test/err_syntax1.tab.c, test/err_syntax1.tab.h, test/yacc/err_syntax1.output, test/yacc/err_syntax1.tab.c, test/yacc/err_syntax1.tab.h: + reference output for testing + + * test/run_test.sh: generate a ".dot" file for the grammar file + + * test/grammar.dot: RCS_BASE + + * test/yacc/grammar.dot: reference output for testing + +2014-03-19 Tom.Shields + + * output.c: rename MAXSHORT to MAXYYINT + +2014-03-18 Tom.Shields + + * yaccpar.skel: skeleton with btyacc additions + + * NOTES-btyacc-Changes: byacc-btyacc-20140323 + + * test/btyacc/btyacc_calc1.output, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_calc1.tab.h: + reference output for testing + + * test/run_make.sh: + move test-outputs into subdirectories to keep btyacc/yacc results separate + + * test/btyacc/pure_calc.tab.c, test/btyacc/pure_calc.tab.h, test/btyacc/pure_error.output, test/btyacc/pure_error.tab.c, test/btyacc/pure_error.tab.h, test/btyacc/quote_calc-s.output, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc-s.tab.h, test/btyacc/quote_calc.output, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc.tab.h, test/btyacc/quote_calc2-s.output, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2-s.tab.h, test/btyacc/quote_calc2.output, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc2.tab.h, test/btyacc/quote_calc3-s.output, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3-s.tab.h, test/btyacc/quote_calc3.output, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc3.tab.h, test/btyacc/quote_calc4-s.output, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4-s.tab.h, test/btyacc/quote_calc4.output, test/btyacc/quote_calc4.tab.c, test/btyacc/quote_calc4.tab.h, test/btyacc/calc1.output, test/btyacc/calc1.tab.c, test/btyacc/calc1.tab.h, test/btyacc/calc2.output, test/btyacc/calc2.tab.c, test/btyacc/calc2.tab.h, test/btyacc/calc3.output, test/btyacc/calc3.tab.c, test/btyacc/calc3.tab.h, test/btyacc/code_calc.code.c, test/btyacc/code_calc.output, test/btyacc/code_calc.tab.c, test/btyacc/code_calc.tab.h, test/btyacc/code_error.code.c, test/btyacc/code_error.output, test/btyacc/code_error.tab.c, test/btyacc/code_error.tab.h, test/btyacc/empty.output, test/btyacc/empty.tab.c, test/btyacc/empty.tab.h, test/btyacc/error.output, test/btyacc/error.tab.c, test/btyacc/error.tab.h, test/btyacc/grammar.output, test/btyacc/grammar.tab.c, test/btyacc/grammar.tab.h, test/btyacc/pure_calc.output, test/btyacc/btyacc_demo.output, test/btyacc/btyacc_demo.tab.h, test/btyacc/calc.output, test/btyacc/calc.tab.c, test/btyacc/calc.tab.h: + reference output for testing + + * defs.h: + several changes to help decouple the use of 'short' as the type of value + used in yacc parsers. + + * NOTES-btyacc-Disposition: byacc-btyacc-20140323 + +2014-03-17 Tom.Shields + + * skel2c, yaccpar.skel, yaccpar.skel.old: RCS_BASE + + * test/run_lint.sh: + move test-outputs into subdirectories to keep btyacc/yacc results separate + + * configure.in: add --with-max-table-size and --enable-btyacc options + +2014-03-16 Tom.Shields + + * main.c: use Value_t rather than short + +2014-03-11 Tom.Shields + + * test/empty.y: testcase for btyacc + +2014-03-10 Tom.Shields + + * test/calc3.y, test/calc2.y: fix unused-variable warning + +2014-02-18 Tom.Shields + + * lr0.c, graph.c: use Value_t rather than short + + * closure.c: use Value_t rather than short + ifdef'd forward-reference prototypes to match ifdef'ing of the actual functions + + * lalr.c: rename MAXSHORT to MAXYYINT + +2014-01-01 Thomas E. Dickey + + * yacc.1: document %token-table, improve presentation of double-quotes + + * VERSION, package/byacc.spec, package/debian/changelog: bump + + * test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_calc.tab.c, test/yacc/code_error.code.c, test/yacc/code_error.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c: + reference output for testing + + * test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_calc.tab.c, test/code_error.code.c, test/code_error.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2-s.tab.c, test/quote_calc2.tab.c, test/quote_calc3-s.tab.c, test/quote_calc3.tab.c, test/quote_calc4-s.tab.c, test/quote_calc4.tab.c: + regen + + * output.c, skeleton.c: + amend the last change so that yytname is #define'd as needed rather than + permanent - to avoid breaking cproto for instance. + +2014-01-01 Christos.Zoulas + + * output.c, defs.h, main.c, reader.c, skeleton.c: + changes to build ntpd using byacc: + - rename yyname[] to yytname[] + - add YYTRANSLATE() macro + - recognize bison's %token-table declaration + +2014-01-01 Thomas E. Dickey + + * configure: regen + + * yacc.1: s/EE/XE/ to work around groff bug on Debian 6 + + * makefile.in: use CF_MAKE_DOCS + + * aclocal.m4: add CF_MAKE_DOCS + + * configure.in: use CF_MAKE_DOCS + +2013-12-26 Thomas E. Dickey + + * config.guess: 2013-11-29 + +2013-11-19 Thomas E. Dickey + + * aclocal.m4: resync with my-autoconf (fixes for clang and mingw) + +2013-10-25 Thomas E. Dickey + + * config.sub: 2013-10-01 + +2013-09-25 Thomas E. Dickey + + * reader.c: fix two loop-limits found by clang 3.3 --analyze + + * configure: regen + + * aclocal.m4: + tweaks to CF_MIXEDCASE_FILENAMES and CF_XOPEN_SOURCE for msys from ncurses + + * package/mingw-byacc.spec: RCS_BASE + + * test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2-s.tab.c, test/quote_calc2.tab.c, test/quote_calc3-s.tab.c, test/quote_calc3.tab.c, test/quote_calc4-s.tab.c, test/quote_calc4.tab.c: + regen + + * skeleton.c: + Increase default stack-size to match FreeBSD version noted as from + "BSD 4.4 Lite Usr.bin Sources". See + + http://svnweb.freebsd.org/base/vendor/CSRG/dist/usr.bin/yacc/ + http://svnweb.freebsd.org/base/head/usr.bin/yacc/ + http://svnweb.freebsd.org/base/vendor/byacc/ + + The original 1.9 sources (on which I based development) used 500 for + stacksize; the BSD Lite sources (a year or two later) used 10000. + + This is a change to default values; the YYMAXDEPTH and YYSTACKSIZE + symbols have "always" been overridable by applications, but rarely + needed to do this. RedHat began using the FreeBSD source in 2000, + and switched to this source in 2007 using the 20050813 snapshot. + + RedHat #743343 misattributed the change in default stacksize to + a regression in byacc, but did not report the issue upstream. + + * package/debian/changelog, VERSION, package/byacc.spec: bump + +2013-09-07 Thomas E. Dickey + + * config.sub: update to 2013-09-15 + + * config.guess: update to 2013-06-10 + 2013-03-04 Thomas E. Dickey * package/debian/changelog, VERSION, package/byacc.spec: bump @@ -30,7 +794,7 @@ 2013-02-10 Thomas E. Dickey - * config.sub, config.guess: 2013-02-04 + * config.sub, config.guess: update to 2013-02-04 2012-10-03 Thomas E. Dickey @@ -162,6 +926,8 @@ * VERSION, package/debian/changelog, package/byacc.spec: bump + * test/yacc/calc1.output: reference output for testing + * test/calc1.output, test/calc1.tab.c: regen * test/calc1.y: @@ -181,6 +947,8 @@ * test/calc2.tab.c, test/calc3.tab.c, test/code_error.code.c, test/ftp.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c: regen + * test/code_debug.y: RCS_BASE + * test/calc2.y, test/calc3.y, test/code_error.y, test/ftp.y: byacc already declares yyerror @@ -273,6 +1041,9 @@ * test/quote_calc-s.output, test/quote_calc-s.tab.c, test/quote_calc-s.tab.h, test/quote_calc2-s.output, test/quote_calc2-s.tab.c, test/quote_calc2-s.tab.h, test/quote_calc3-s.output, test/quote_calc3-s.tab.c, test/quote_calc3-s.tab.h, test/quote_calc4-s.output, test/quote_calc4-s.tab.c, test/quote_calc4-s.tab.h: RCS_BASE + * test/yacc/quote_calc-s.output, test/yacc/quote_calc-s.tab.h, test/yacc/quote_calc2-s.output, test/yacc/quote_calc2-s.tab.h, test/yacc/quote_calc3-s.output, test/yacc/quote_calc3-s.tab.h, test/yacc/quote_calc4-s.output, test/yacc/quote_calc4-s.tab.h: + reference output for testing + * test/run_test.sh: generate/test with "-s" option applied. 2012-01-13 Thomas E. Dickey @@ -285,9 +1056,24 @@ * main.c: add -s option to usage message. - * test/quote_calc3.output, test/quote_calc3.tab.c, test/quote_calc4.output, test/quote_calc4.tab.c, test/quote_calc4.tab.h, test/quote_calc3.y, test/quote_calc.tab.h, test/quote_calc.output, test/quote_calc.tab.c, test/quote_calc2.output, test/quote_calc2.tab.c, test/quote_calc2.tab.h, test/quote_calc3.tab.h, test/quote_calc4.y, test/quote_calc.y, test/quote_calc2.y: + * test/quote_calc3.output, test/quote_calc3.tab.c, test/quote_calc4.output, test/quote_calc4.tab.c, test/quote_calc4.tab.h: + RCS_BASE + + * test/yacc/quote_calc3.output, test/yacc/quote_calc4.output, test/yacc/quote_calc4.tab.h: + reference output for testing + + * test/quote_calc3.y, test/quote_calc.tab.h: RCS_BASE + + * test/yacc/quote_calc.tab.h: reference output for testing + + * test/quote_calc.output, test/quote_calc.tab.c, test/quote_calc2.output, test/quote_calc2.tab.c, test/quote_calc2.tab.h, test/quote_calc3.tab.h: RCS_BASE + * test/yacc/quote_calc.output, test/yacc/quote_calc2.output, test/yacc/quote_calc2.tab.h, test/yacc/quote_calc3.tab.h: + reference output for testing + + * test/quote_calc4.y, test/quote_calc.y, test/quote_calc2.y: RCS_BASE + * configure: regen * aclocal.m4: resync with my-autoconf, i.e., fixes for CF_XOPEN_SOURCE @@ -348,11 +1134,11 @@ 2011-04-01 Thomas E. Dickey - * config.sub: 2011-04-01 + * config.sub: update to 2011-04-01 2011-02-02 Thomas E. Dickey - * config.guess: 2011-01-01 + * config.guess: update to 2011-01-01 2010-12-29 Thomas E. Dickey @@ -470,6 +1256,8 @@ * output.c: simplified a little, using putc_code() and putl_code() + * test/yacc/calc1.tab.h: reference output for testing + * test/calc1.tab.h: regen * reader.c: @@ -530,11 +1318,11 @@ 2010-09-28 Thomas E. Dickey - * config.guess: 2010-09-24 + * config.guess: update to 2010-09-24 2010-09-10 Thomas E. Dickey - * config.sub: 2010-09-11 + * config.sub: update to 2010-09-11 2010-06-10 Thomas E. Dickey @@ -551,9 +1339,20 @@ improve %lex-param / %parse-param implementation by allowing for arrays to be passed as parameters, e.g., "int regs[26]". - * test/calc3.tab.c, test/calc3.y, test/calc3.output, test/calc3.tab.h, test/calc2.tab.c, test/calc2.y, test/calc2.tab.h, test/calc2.output: + * test/calc3.tab.c, test/calc3.y, test/calc3.output, test/calc3.tab.h: RCS_BASE + * test/yacc/calc3.output, test/yacc/calc3.tab.h: + reference output for testing + + * test/calc2.tab.c, test/calc2.y, test/calc2.tab.h: RCS_BASE + + * test/yacc/calc2.tab.h: reference output for testing + + * test/calc2.output: RCS_BASE + + * test/yacc/calc2.output: reference output for testing + * output.c: improve %lex-param / %parse-param implementation by allowing for arrays to be passed as parameters, e.g., "int regs[26]". @@ -613,9 +1412,27 @@ provide for testing -r and -P options by checking if the ".y" filename begins with "code_" or "pure_", respectively. - * test/code_error.code.c, test/code_error.tab.c, test/code_error.tab.h, test/code_calc.code.c, test/code_calc.tab.c, test/code_calc.tab.h, test/pure_calc.output, test/pure_calc.tab.h, test/pure_error.output, test/pure_error.tab.h, test/code_calc.output, test/code_error.output: + * test/code_error.code.c, test/code_error.tab.c, test/code_error.tab.h: + RCS_BASE + + * test/yacc/code_error.tab.h: reference output for testing + + * test/code_calc.code.c, test/code_calc.tab.c, test/code_calc.tab.h: RCS_BASE + * test/yacc/code_calc.tab.h: reference output for testing + + * test/pure_calc.output, test/pure_calc.tab.h, test/pure_error.output, test/pure_error.tab.h: + RCS_BASE + + * test/yacc/pure_calc.output, test/yacc/pure_calc.tab.h, test/yacc/pure_error.output, test/yacc/pure_error.tab.h: + reference output for testing + + * test/code_calc.output, test/code_error.output: RCS_BASE + + * test/yacc/code_calc.output, test/yacc/code_error.output: + reference output for testing + * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: regen * test/run_test.sh: @@ -770,9 +1587,9 @@ 2009-12-31 Thomas E. Dickey - * config.guess: 2009-12-30 + * config.guess: update to 2009-12-30 - * config.sub: 2009-12-31 + * config.sub: update to 2009-12-31 2009-10-27 Thomas E. Dickey @@ -798,7 +1615,7 @@ 2009-08-25 Thomas E. Dickey - * config.guess, config.sub: 2009-08-19 + * config.guess, config.sub: update to 2009-08-19 2009-02-21 Thomas E. Dickey @@ -979,11 +1796,11 @@ 2006-12-22 Thomas E. Dickey - * config.guess: 2006/12/22 + * config.guess: update to 2006/12/22 2006-12-08 Thomas E. Dickey - * config.sub: 2006/12/08 + * config.sub: update to 2006/12/08 2005-08-13 Thomas E. Dickey @@ -1012,9 +1829,9 @@ 2005-06-25 Thomas E. Dickey - * config.sub: 2005/6/2 + * config.sub: update to 2005/6/2 - * config.guess: 2005/5/27 + * config.guess: update to 2005/5/27 2005-05-05 Thomas E. Dickey @@ -1108,9 +1925,9 @@ 2005-04-16 Thomas E. Dickey - * config.sub: 2005/2/10 + * config.sub: update to 2005/2/10 - * config.guess: 2005/3/24 + * config.guess: update to 2005/3/24 2005-04-13 Thomas E. Dickey @@ -1164,9 +1981,18 @@ * test/grammar.output, test/grammar.tab.c, test/grammar.tab.h: RCS_BASE + * test/yacc/grammar.output, test/yacc/grammar.tab.h: + reference output for testing + * makefile.in: turn on "make check" rule - * test/calc.output, test/run_test.sh, test/calc.tab.h: RCS_BASE + * test/calc.output: RCS_BASE + + * test/yacc/calc.output: reference output for testing + + * test/run_test.sh, test/calc.tab.h: RCS_BASE + + * test/yacc/calc.tab.h: reference output for testing * test/ftp.tab.c: yyparse() is now yyparse(void) @@ -1252,8 +2078,16 @@ 1993-02-22 unknown - * test/ftp.output, test/ftp.tab.c, test/ftp.tab.h, test/error.output, test/error.tab.c, test/error.tab.h: - RCS_BASE + * test/ftp.output, test/ftp.tab.c, test/ftp.tab.h: RCS_BASE + +1993-02-22 Thomas E. Dickey + + * test/yacc/error.output, test/yacc/error.tab.h: + reference output for testing + +1993-02-22 unknown + + * test/error.output, test/error.tab.c, test/error.tab.h: RCS_BASE * skeleton.c, warshall.c, main.c, output.c, reader.c, closure.c, NOTES: original version diff --git a/contrib/byacc/MANIFEST b/contrib/byacc/MANIFEST new file mode 100644 index 000000000..271d9c81d --- /dev/null +++ b/contrib/byacc/MANIFEST @@ -0,0 +1,667 @@ +MANIFEST for byacc-20140422, version t20140422 +-------------------------------------------------------------------------------- +MANIFEST this file +ACKNOWLEDGEMENTS original version of byacc - 1993 +AUTHORS nicknames for some contributors (see CHANGES for details) +Makefile.old renamed from Makefile +NEW_FEATURES original version of byacc - 1993 +NOTES original version of byacc - 1993 +NO_WARRANTY original version of byacc - 1993 +README original version of byacc - 1993 +README.BTYACC byacc-btyacc-20140323 +VERSION patch-level +aclocal.m4 macros for configure-script +btyaccpar.c generated from btyaccpar.skel +btyaccpar.skel bytacc's parser skeleton (renamed from yaccpar.skel) +closure.c original version of byacc - 1993 +config.guess configure-script utility +config.sub configure-script utility +config_h.in template for config.h +configure snapshot 2004/3/28 +configure.in template for configure-script +defs.h original version of byacc - 1993 +descrip.mms build-script for VMS +error.c original version of byacc - 1993 +graph.c write the file y.dot in graphviz format +install-sh install-script +lalr.c original version of byacc - 1993 +lr0.c original version of byacc - 1993 +main.c original version of byacc - 1993 +makefile.in template for makefile +mkpar.c original version of byacc - 1993 +mstring.c string-utilities +output.c original version of byacc - 1993 +reader.c original version of byacc - 1993 +skel2c awk script to transform yaccpar.skel into skeleton.c +symtab.c original version of byacc - 1993 +verbose.c original version of byacc - 1993 +vmsbuild.com build-script for VMS +warshall.c original version of byacc - 1993 +yacc.1 original version of byacc - 1993 +yaccpar.c generated from yaccpar.skel +yaccpar.skel data which can be transformed into skeleton.c +package subdirectory +package/byacc.spec RPM file for byacc +package/debian subdirectory +package/debian/changelog scripts from Debian package +package/debian/compat scripts from Debian package +package/debian/control scripts from Debian package +package/debian/copyright scripts from Debian package +package/debian/docs scripts from Debian package +package/debian/postinst scripts from Debian package +package/debian/prerm scripts from Debian package +package/debian/rules scripts from Debian package +package/debian/source subdirectory +package/debian/source/format scripts from Debian package +package/debian subdirectory +package/debian/watch scripts from Debian package +package subdirectory +package/mingw-byacc.spec mingw spec-file, for cross-compiles +package/pkgsrc subdirectory +package/pkgsrc/DESCR scripts from NetBSD pkgsrc, for test-builds +package/pkgsrc/Makefile scripts from NetBSD pkgsrc, for test-builds +package/pkgsrc/PLIST scripts from NetBSD pkgsrc, for test-builds +package/pkgsrc/distinfo scripts from NetBSD pkgsrc, for test-builds +test subdirectory +test/README describe contents of "test" subdirectory +test/btyacc subdirectory +test/btyacc/big_b.error exercise -L/-B options +test/btyacc/big_b.output exercise -L/-B options +test/btyacc/big_l.error exercise -L/-B options +test/btyacc/big_l.output exercise -L/-B options +test/btyacc/btyacc_calc1.error reference output for testing +test/btyacc/btyacc_calc1.output reference output for testing +test/btyacc/btyacc_calc1.tab.c reference output for testing +test/btyacc/btyacc_calc1.tab.h reference output for testing +test/btyacc/btyacc_demo.error reference output for testing +test/btyacc/btyacc_demo.output reference output for testing +test/btyacc/btyacc_demo.tab.c reference output for testing +test/btyacc/btyacc_demo.tab.h reference output for testing +test/btyacc/calc.error reference output for testing +test/btyacc/calc.output reference output for testing +test/btyacc/calc.tab.c reference output for testing +test/btyacc/calc.tab.h reference output for testing +test/btyacc/calc1.error reference output for testing +test/btyacc/calc1.output reference output for testing +test/btyacc/calc1.tab.c reference output for testing +test/btyacc/calc1.tab.h reference output for testing +test/btyacc/calc2.error reference output for testing +test/btyacc/calc2.output reference output for testing +test/btyacc/calc2.tab.c reference output for testing +test/btyacc/calc2.tab.h reference output for testing +test/btyacc/calc3.error reference output for testing +test/btyacc/calc3.output reference output for testing +test/btyacc/calc3.tab.c reference output for testing +test/btyacc/calc3.tab.h reference output for testing +test/btyacc/code_calc.code.c reference output for testing +test/btyacc/code_calc.error reference output for testing +test/btyacc/code_calc.output reference output for testing +test/btyacc/code_calc.tab.c reference output for testing +test/btyacc/code_calc.tab.h reference output for testing +test/btyacc/code_debug.c reference for test-output +test/btyacc/code_debug.error reference for test-output +test/btyacc/code_debug.h reference for test-output +test/btyacc/code_debug.i reference for test-output +test/btyacc/code_debug.output reference for test-output +test/btyacc/code_error.code.c reference output for testing +test/btyacc/code_error.error reference output for testing +test/btyacc/code_error.output reference output for testing +test/btyacc/code_error.tab.c reference output for testing +test/btyacc/code_error.tab.h reference output for testing +test/btyacc/empty.error reference output for testing +test/btyacc/empty.output reference output for testing +test/btyacc/empty.tab.c reference output for testing +test/btyacc/empty.tab.h reference output for testing +test/btyacc/err_inherit1.error reference output for testing +test/btyacc/err_inherit1.output reference output for testing +test/btyacc/err_inherit1.tab.c reference output for testing +test/btyacc/err_inherit1.tab.h reference output for testing +test/btyacc/err_inherit2.error reference output for testing +test/btyacc/err_inherit2.output reference output for testing +test/btyacc/err_inherit2.tab.c reference output for testing +test/btyacc/err_inherit2.tab.h reference output for testing +test/btyacc/err_inherit3.error reference output for testing +test/btyacc/err_inherit3.output reference output for testing +test/btyacc/err_inherit3.tab.c reference output for testing +test/btyacc/err_inherit3.tab.h reference output for testing +test/btyacc/err_inherit4.error reference output for testing +test/btyacc/err_inherit4.output reference output for testing +test/btyacc/err_inherit4.tab.c reference output for testing +test/btyacc/err_inherit4.tab.h reference output for testing +test/btyacc/err_inherit5.error reference output for testing +test/btyacc/err_inherit5.output reference output for testing +test/btyacc/err_inherit5.tab.c reference output for testing +test/btyacc/err_inherit5.tab.h reference output for testing +test/btyacc/err_syntax1.error reference output for testing +test/btyacc/err_syntax1.output reference output for testing +test/btyacc/err_syntax1.tab.c reference output for testing +test/btyacc/err_syntax1.tab.h reference output for testing +test/btyacc/err_syntax10.error reference output for testing +test/btyacc/err_syntax10.output reference output for testing +test/btyacc/err_syntax10.tab.c reference output for testing +test/btyacc/err_syntax10.tab.h reference output for testing +test/btyacc/err_syntax11.error reference output for testing +test/btyacc/err_syntax11.output reference output for testing +test/btyacc/err_syntax11.tab.c reference output for testing +test/btyacc/err_syntax11.tab.h reference output for testing +test/btyacc/err_syntax12.error reference output for testing +test/btyacc/err_syntax12.output reference output for testing +test/btyacc/err_syntax12.tab.c reference output for testing +test/btyacc/err_syntax12.tab.h reference output for testing +test/btyacc/err_syntax13.error reference output for testing +test/btyacc/err_syntax13.output reference output for testing +test/btyacc/err_syntax13.tab.c reference output for testing +test/btyacc/err_syntax13.tab.h reference output for testing +test/btyacc/err_syntax14.error reference output for testing +test/btyacc/err_syntax14.output reference output for testing +test/btyacc/err_syntax14.tab.c reference output for testing +test/btyacc/err_syntax14.tab.h reference output for testing +test/btyacc/err_syntax15.error reference output for testing +test/btyacc/err_syntax15.output reference output for testing +test/btyacc/err_syntax15.tab.c reference output for testing +test/btyacc/err_syntax15.tab.h reference output for testing +test/btyacc/err_syntax16.error reference output for testing +test/btyacc/err_syntax16.output reference output for testing +test/btyacc/err_syntax16.tab.c reference output for testing +test/btyacc/err_syntax16.tab.h reference output for testing +test/btyacc/err_syntax17.error reference output for testing +test/btyacc/err_syntax17.output reference output for testing +test/btyacc/err_syntax17.tab.c reference output for testing +test/btyacc/err_syntax17.tab.h reference output for testing +test/btyacc/err_syntax18.error reference output for testing +test/btyacc/err_syntax18.output reference output for testing +test/btyacc/err_syntax18.tab.c reference output for testing +test/btyacc/err_syntax18.tab.h reference output for testing +test/btyacc/err_syntax19.error reference output for testing +test/btyacc/err_syntax19.output reference output for testing +test/btyacc/err_syntax19.tab.c reference output for testing +test/btyacc/err_syntax19.tab.h reference output for testing +test/btyacc/err_syntax2.error reference output for testing +test/btyacc/err_syntax2.output reference output for testing +test/btyacc/err_syntax2.tab.c reference output for testing +test/btyacc/err_syntax2.tab.h reference output for testing +test/btyacc/err_syntax20.error reference output for testing +test/btyacc/err_syntax20.output reference output for testing +test/btyacc/err_syntax20.tab.c reference output for testing +test/btyacc/err_syntax20.tab.h reference output for testing +test/btyacc/err_syntax21.error reference output for testing +test/btyacc/err_syntax21.output reference output for testing +test/btyacc/err_syntax21.tab.c reference output for testing +test/btyacc/err_syntax21.tab.h reference output for testing +test/btyacc/err_syntax22.error reference output for testing +test/btyacc/err_syntax22.output reference output for testing +test/btyacc/err_syntax22.tab.c reference output for testing +test/btyacc/err_syntax22.tab.h reference output for testing +test/btyacc/err_syntax23.error reference output for testing +test/btyacc/err_syntax23.output reference output for testing +test/btyacc/err_syntax23.tab.c reference output for testing +test/btyacc/err_syntax23.tab.h reference output for testing +test/btyacc/err_syntax24.error reference output for testing +test/btyacc/err_syntax24.output reference output for testing +test/btyacc/err_syntax24.tab.c reference output for testing +test/btyacc/err_syntax24.tab.h reference output for testing +test/btyacc/err_syntax25.error reference output for testing +test/btyacc/err_syntax25.output reference output for testing +test/btyacc/err_syntax25.tab.c reference output for testing +test/btyacc/err_syntax25.tab.h reference output for testing +test/btyacc/err_syntax26.error reference output for testing +test/btyacc/err_syntax26.output reference output for testing +test/btyacc/err_syntax26.tab.c reference output for testing +test/btyacc/err_syntax26.tab.h reference output for testing +test/btyacc/err_syntax27.error reference output for testing +test/btyacc/err_syntax27.output reference output for testing +test/btyacc/err_syntax27.tab.c reference output for testing +test/btyacc/err_syntax27.tab.h reference output for testing +test/btyacc/err_syntax3.error reference output for testing +test/btyacc/err_syntax3.output reference output for testing +test/btyacc/err_syntax3.tab.c reference output for testing +test/btyacc/err_syntax3.tab.h reference output for testing +test/btyacc/err_syntax4.error reference output for testing +test/btyacc/err_syntax4.output reference output for testing +test/btyacc/err_syntax4.tab.c reference output for testing +test/btyacc/err_syntax4.tab.h reference output for testing +test/btyacc/err_syntax5.error reference output for testing +test/btyacc/err_syntax5.output reference output for testing +test/btyacc/err_syntax5.tab.c reference output for testing +test/btyacc/err_syntax5.tab.h reference output for testing +test/btyacc/err_syntax6.error reference output for testing +test/btyacc/err_syntax6.output reference output for testing +test/btyacc/err_syntax6.tab.c reference output for testing +test/btyacc/err_syntax6.tab.h reference output for testing +test/btyacc/err_syntax7.error reference output for testing +test/btyacc/err_syntax7.output reference output for testing +test/btyacc/err_syntax7.tab.c reference output for testing +test/btyacc/err_syntax7.tab.h reference output for testing +test/btyacc/err_syntax7a.error reference output for testing +test/btyacc/err_syntax7a.output reference output for testing +test/btyacc/err_syntax7a.tab.c reference output for testing +test/btyacc/err_syntax7a.tab.h reference output for testing +test/btyacc/err_syntax7b.error reference output for testing +test/btyacc/err_syntax7b.output reference output for testing +test/btyacc/err_syntax7b.tab.c reference output for testing +test/btyacc/err_syntax7b.tab.h reference output for testing +test/btyacc/err_syntax8.error reference output for testing +test/btyacc/err_syntax8.output reference output for testing +test/btyacc/err_syntax8.tab.c reference output for testing +test/btyacc/err_syntax8.tab.h reference output for testing +test/btyacc/err_syntax8a.error reference output for testing +test/btyacc/err_syntax8a.output reference output for testing +test/btyacc/err_syntax8a.tab.c reference output for testing +test/btyacc/err_syntax8a.tab.h reference output for testing +test/btyacc/err_syntax9.error reference output for testing +test/btyacc/err_syntax9.output reference output for testing +test/btyacc/err_syntax9.tab.c reference output for testing +test/btyacc/err_syntax9.tab.h reference output for testing +test/btyacc/error.error reference output for testing +test/btyacc/error.output reference output for testing +test/btyacc/error.tab.c reference output for testing +test/btyacc/error.tab.h reference output for testing +test/btyacc/grammar.dot reference output for testing +test/btyacc/grammar.error reference output for testing +test/btyacc/grammar.output reference output for testing +test/btyacc/grammar.tab.c reference output for testing +test/btyacc/grammar.tab.h reference output for testing +test/btyacc/help.error reference output for testing +test/btyacc/help.output reference output for testing +test/btyacc/inherit0.error reference output for testing +test/btyacc/inherit0.output reference output for testing +test/btyacc/inherit0.tab.c reference output for testing +test/btyacc/inherit0.tab.h reference output for testing +test/btyacc/inherit1.error reference output for testing +test/btyacc/inherit1.output reference output for testing +test/btyacc/inherit1.tab.c reference output for testing +test/btyacc/inherit1.tab.h reference output for testing +test/btyacc/inherit2.error reference output for testing +test/btyacc/inherit2.output reference output for testing +test/btyacc/inherit2.tab.c reference output for testing +test/btyacc/inherit2.tab.h reference output for testing +test/btyacc/no_b_opt.error reference output for testing +test/btyacc/no_b_opt.output reference output for testing +test/btyacc/no_b_opt1.error reference output for testing +test/btyacc/no_b_opt1.output reference output for testing +test/btyacc/no_code_c.error reference output for testing +test/btyacc/no_code_c.output reference output for testing +test/btyacc/no_defines.error reference output for testing +test/btyacc/no_defines.output reference output for testing +test/btyacc/no_graph.error reference output for testing +test/btyacc/no_graph.output reference output for testing +test/btyacc/no_include.error reference output for testing +test/btyacc/no_include.output reference output for testing +test/btyacc/no_opts.error reference output for testing +test/btyacc/no_opts.output reference output for testing +test/btyacc/no_output.error reference output for testing +test/btyacc/no_output.output reference output for testing +test/btyacc/no_output1.error reference output for testing +test/btyacc/no_output1.output reference output for testing +test/btyacc/no_output2.error reference output for testing +test/btyacc/no_output2.output reference output for testing +test/btyacc/no_p_opt.error reference output for testing +test/btyacc/no_p_opt.output reference output for testing +test/btyacc/no_p_opt1.error reference output for testing +test/btyacc/no_p_opt1.output reference output for testing +test/btyacc/no_verbose.error reference output for testing +test/btyacc/no_verbose.output reference output for testing +test/btyacc/nostdin.error reference output for testing +test/btyacc/nostdin.output reference output for testing +test/btyacc/ok_syntax1.error reference output for testing +test/btyacc/ok_syntax1.output reference output for testing +test/btyacc/ok_syntax1.tab.c reference output for testing +test/btyacc/ok_syntax1.tab.h reference output for testing +test/btyacc/pure_calc.error reference output for testing +test/btyacc/pure_calc.output reference output for testing +test/btyacc/pure_calc.tab.c reference output for testing +test/btyacc/pure_calc.tab.h reference output for testing +test/btyacc/pure_error.error reference output for testing +test/btyacc/pure_error.output reference output for testing +test/btyacc/pure_error.tab.c reference output for testing +test/btyacc/pure_error.tab.h reference output for testing +test/btyacc/quote_calc-s.error reference output for testing +test/btyacc/quote_calc-s.output reference output for testing +test/btyacc/quote_calc-s.tab.c reference output for testing +test/btyacc/quote_calc-s.tab.h reference output for testing +test/btyacc/quote_calc.error reference output for testing +test/btyacc/quote_calc.output reference output for testing +test/btyacc/quote_calc.tab.c reference output for testing +test/btyacc/quote_calc.tab.h reference output for testing +test/btyacc/quote_calc2-s.error reference output for testing +test/btyacc/quote_calc2-s.output reference output for testing +test/btyacc/quote_calc2-s.tab.c reference output for testing +test/btyacc/quote_calc2-s.tab.h reference output for testing +test/btyacc/quote_calc2.error reference output for testing +test/btyacc/quote_calc2.output reference output for testing +test/btyacc/quote_calc2.tab.c reference output for testing +test/btyacc/quote_calc2.tab.h reference output for testing +test/btyacc/quote_calc3-s.error reference output for testing +test/btyacc/quote_calc3-s.output reference output for testing +test/btyacc/quote_calc3-s.tab.c reference output for testing +test/btyacc/quote_calc3-s.tab.h reference output for testing +test/btyacc/quote_calc3.error reference output for testing +test/btyacc/quote_calc3.output reference output for testing +test/btyacc/quote_calc3.tab.c reference output for testing +test/btyacc/quote_calc3.tab.h reference output for testing +test/btyacc/quote_calc4-s.error reference output for testing +test/btyacc/quote_calc4-s.output reference output for testing +test/btyacc/quote_calc4-s.tab.c reference output for testing +test/btyacc/quote_calc4-s.tab.h reference output for testing +test/btyacc/quote_calc4.error reference output for testing +test/btyacc/quote_calc4.output reference output for testing +test/btyacc/quote_calc4.tab.c reference output for testing +test/btyacc/quote_calc4.tab.h reference output for testing +test/btyacc/rename_debug.c reference output for testing +test/btyacc/rename_debug.error reference output for testing +test/btyacc/rename_debug.h reference output for testing +test/btyacc/rename_debug.i reference output for testing +test/btyacc/rename_debug.output reference output for testing +test/btyacc/varsyntax_calc1.error reference output for testing +test/btyacc/varsyntax_calc1.output reference output for testing +test/btyacc/varsyntax_calc1.tab.c reference output for testing +test/btyacc/varsyntax_calc1.tab.h reference output for testing +test subdirectory +test/btyacc_calc1.y testcase for btyacc +test/btyacc_demo.y testcase for btyacc +test/calc.y example from VMS freeware version of byacc +test/calc1.y advanced example from Steve Johnson's paper. +test/calc2.y test-cases and reference files for %lex-param / %parse-param +test/calc3.y test-cases and reference files for %lex-param / %parse-param +test/code_calc.y reference input for testing +test/code_debug.y test-input, for -i, -o, -d options +test/code_error.y reference input for testing +test/empty.y testcase for btyacc +test/err_inherit1.y testcase for btyacc +test/err_inherit2.y testcase for btyacc +test/err_inherit3.y testcase for btyacc +test/err_inherit4.y testcase for btyacc +test/err_inherit5.y testcase for btyacc +test/err_syntax1.y test-case with syntax error (and nonprinting character) +test/err_syntax10.y testcase for retyped_warning() +test/err_syntax11.y testcase for reprec_warning() +test/err_syntax12.y testcase for revalued_warning() +test/err_syntax13.y testcase for terminal_start() +test/err_syntax14.y testcase for restarted_warning() and undefined_goal() +test/err_syntax15.y testcase for no_grammar() +test/err_syntax16.y testcase for terminal_lhs() +test/err_syntax17.y testcase for unterminated_action() +test/err_syntax18.y testcase for dollar_warning() +test/err_syntax19.y testcase for dollar_error() +test/err_syntax2.y testcase for unterminated_comment() +test/err_syntax20.y testcase for undefined_symbol_warning() +test/err_syntax21.y testcase for unknown_rhs() +test/err_syntax22.y testcase for untyped_rhs() +test/err_syntax23.y testcase for untyped_lhs() +test/err_syntax24.y testcase for default_action_warning() +test/err_syntax25.y testcase for over_unionized() +test/err_syntax26.y testcase for unexpected_EOF() +test/err_syntax27.y testcase for missing_brace() +test/err_syntax3.y testcase for unterminated_string() +test/err_syntax4.y testcase for unterminated_text() +test/err_syntax5.y testcase for unterminated_union() +test/err_syntax6.y testcase for illegal_tag() +test/err_syntax7.y testcase for illegal_character() +test/err_syntax7a.y testcase for illegal_character() +test/err_syntax7b.y testcase for illegal_character() +test/err_syntax8.y testcase for used_reserved() +test/err_syntax8a.y testcase for used_reserved() +test/err_syntax9.y testcase for tokenized_start() +test/error.y original version of byacc - 1993 +test/grammar.y grammar from cproto +test/inherit0.y testcase for btyacc +test/inherit1.y testcase for btyacc +test/inherit2.y testcase for btyacc +test/ok_syntax1.y testcase for valid literal syntax +test/pure_calc.y reference input for testing +test/pure_error.y reference input for testing +test/quote_calc.y test-case for %token using quoted name +test/quote_calc2.y test-case for %token using quoted name +test/quote_calc3.y test-case for %token using quoted name +test/quote_calc4.y test-case for %token using quoted name +test/run_lint.sh run lint, using the build-directory's makefile, on each ".c" file in test-directory +test/run_make.sh do a test-compile of each ".c" file in the test-directory +test/run_test.sh test-script for byacc +test/varsyntax_calc1.y testcase for btyacc +test/yacc subdirectory +test/yacc/big_b.error exercise -L/-B options +test/yacc/big_b.output exercise -L/-B options +test/yacc/big_l.error exercise -L/-B options +test/yacc/big_l.output exercise -L/-B options +test/yacc/calc.error reference output for testing +test/yacc/calc.output reference output for testing +test/yacc/calc.tab.c reference output for testing +test/yacc/calc.tab.h reference output for testing +test/yacc/calc1.error reference output for testing +test/yacc/calc1.output reference output for testing +test/yacc/calc1.tab.c reference output for testing +test/yacc/calc1.tab.h reference output for testing +test/yacc/calc2.error reference output for testing +test/yacc/calc2.output reference output for testing +test/yacc/calc2.tab.c reference output for testing +test/yacc/calc2.tab.h reference output for testing +test/yacc/calc3.error reference output for testing +test/yacc/calc3.output reference output for testing +test/yacc/calc3.tab.c reference output for testing +test/yacc/calc3.tab.h reference output for testing +test/yacc/code_calc.code.c reference output for testing +test/yacc/code_calc.error reference output for testing +test/yacc/code_calc.output reference output for testing +test/yacc/code_calc.tab.c reference output for testing +test/yacc/code_calc.tab.h reference output for testing +test/yacc/code_error.code.c reference output for testing +test/yacc/code_error.error reference output for testing +test/yacc/code_error.output reference output for testing +test/yacc/code_error.tab.c reference output for testing +test/yacc/code_error.tab.h reference output for testing +test/yacc/empty.error reference output for testing +test/yacc/empty.output reference output for testing +test/yacc/empty.tab.c reference output for testing +test/yacc/empty.tab.h reference output for testing +test/yacc/err_syntax1.error reference output for testing +test/yacc/err_syntax1.output reference output for testing +test/yacc/err_syntax1.tab.c reference output for testing +test/yacc/err_syntax1.tab.h reference output for testing +test/yacc/err_syntax10.error reference output for testing +test/yacc/err_syntax10.output reference output for testing +test/yacc/err_syntax10.tab.c reference output for testing +test/yacc/err_syntax10.tab.h reference output for testing +test/yacc/err_syntax11.error reference output for testing +test/yacc/err_syntax11.output reference output for testing +test/yacc/err_syntax11.tab.c reference output for testing +test/yacc/err_syntax11.tab.h reference output for testing +test/yacc/err_syntax12.error reference output for testing +test/yacc/err_syntax12.output reference output for testing +test/yacc/err_syntax12.tab.c reference output for testing +test/yacc/err_syntax12.tab.h reference output for testing +test/yacc/err_syntax13.error reference output for testing +test/yacc/err_syntax13.output reference output for testing +test/yacc/err_syntax13.tab.c reference output for testing +test/yacc/err_syntax13.tab.h reference output for testing +test/yacc/err_syntax14.error reference output for testing +test/yacc/err_syntax14.output reference output for testing +test/yacc/err_syntax14.tab.c reference output for testing +test/yacc/err_syntax14.tab.h reference output for testing +test/yacc/err_syntax15.error reference output for testing +test/yacc/err_syntax15.output reference output for testing +test/yacc/err_syntax15.tab.c reference output for testing +test/yacc/err_syntax15.tab.h reference output for testing +test/yacc/err_syntax16.error reference output for testing +test/yacc/err_syntax16.output reference output for testing +test/yacc/err_syntax16.tab.c reference output for testing +test/yacc/err_syntax16.tab.h reference output for testing +test/yacc/err_syntax17.error reference output for testing +test/yacc/err_syntax17.output reference output for testing +test/yacc/err_syntax17.tab.c reference output for testing +test/yacc/err_syntax17.tab.h reference output for testing +test/yacc/err_syntax18.error reference output for testing +test/yacc/err_syntax18.output reference output for testing +test/yacc/err_syntax18.tab.c reference output for testing +test/yacc/err_syntax18.tab.h reference output for testing +test/yacc/err_syntax19.error reference output for testing +test/yacc/err_syntax19.output reference output for testing +test/yacc/err_syntax19.tab.c reference output for testing +test/yacc/err_syntax19.tab.h reference output for testing +test/yacc/err_syntax2.error reference output for testing +test/yacc/err_syntax2.output reference output for testing +test/yacc/err_syntax2.tab.c reference output for testing +test/yacc/err_syntax2.tab.h reference output for testing +test/yacc/err_syntax20.error reference output for testing +test/yacc/err_syntax20.output reference output for testing +test/yacc/err_syntax20.tab.c reference output for testing +test/yacc/err_syntax20.tab.h reference output for testing +test/yacc/err_syntax21.error reference output for testing +test/yacc/err_syntax21.output reference output for testing +test/yacc/err_syntax21.tab.c reference output for testing +test/yacc/err_syntax21.tab.h reference output for testing +test/yacc/err_syntax22.error reference output for testing +test/yacc/err_syntax22.output reference output for testing +test/yacc/err_syntax22.tab.c reference output for testing +test/yacc/err_syntax22.tab.h reference output for testing +test/yacc/err_syntax23.error reference output for testing +test/yacc/err_syntax23.output reference output for testing +test/yacc/err_syntax23.tab.c reference output for testing +test/yacc/err_syntax23.tab.h reference output for testing +test/yacc/err_syntax24.error reference output for testing +test/yacc/err_syntax24.output reference output for testing +test/yacc/err_syntax24.tab.c reference output for testing +test/yacc/err_syntax24.tab.h reference output for testing +test/yacc/err_syntax25.error reference output for testing +test/yacc/err_syntax25.output reference output for testing +test/yacc/err_syntax25.tab.c reference output for testing +test/yacc/err_syntax25.tab.h reference output for testing +test/yacc/err_syntax26.error reference output for testing +test/yacc/err_syntax26.output reference output for testing +test/yacc/err_syntax26.tab.c reference output for testing +test/yacc/err_syntax26.tab.h reference output for testing +test/yacc/err_syntax27.error reference output for testing +test/yacc/err_syntax27.output reference output for testing +test/yacc/err_syntax27.tab.c reference output for testing +test/yacc/err_syntax27.tab.h reference output for testing +test/yacc/err_syntax3.error reference output for testing +test/yacc/err_syntax3.output reference output for testing +test/yacc/err_syntax3.tab.c reference output for testing +test/yacc/err_syntax3.tab.h reference output for testing +test/yacc/err_syntax4.error reference output for testing +test/yacc/err_syntax4.output reference output for testing +test/yacc/err_syntax4.tab.c reference output for testing +test/yacc/err_syntax4.tab.h reference output for testing +test/yacc/err_syntax5.error reference output for testing +test/yacc/err_syntax5.output reference output for testing +test/yacc/err_syntax5.tab.c reference output for testing +test/yacc/err_syntax5.tab.h reference output for testing +test/yacc/err_syntax6.error reference output for testing +test/yacc/err_syntax6.output reference output for testing +test/yacc/err_syntax6.tab.c reference output for testing +test/yacc/err_syntax6.tab.h reference output for testing +test/yacc/err_syntax7.error reference output for testing +test/yacc/err_syntax7.output reference output for testing +test/yacc/err_syntax7.tab.c reference output for testing +test/yacc/err_syntax7.tab.h reference output for testing +test/yacc/err_syntax7a.error reference output for testing +test/yacc/err_syntax7a.output reference output for testing +test/yacc/err_syntax7a.tab.c reference output for testing +test/yacc/err_syntax7a.tab.h reference output for testing +test/yacc/err_syntax7b.error reference output for testing +test/yacc/err_syntax7b.output reference output for testing +test/yacc/err_syntax7b.tab.c reference output for testing +test/yacc/err_syntax7b.tab.h reference output for testing +test/yacc/err_syntax8.error reference output for testing +test/yacc/err_syntax8.output reference output for testing +test/yacc/err_syntax8.tab.c reference output for testing +test/yacc/err_syntax8.tab.h reference output for testing +test/yacc/err_syntax8a.error reference output for testing +test/yacc/err_syntax8a.output reference output for testing +test/yacc/err_syntax8a.tab.c reference output for testing +test/yacc/err_syntax8a.tab.h reference output for testing +test/yacc/err_syntax9.error reference output for testing +test/yacc/err_syntax9.output reference output for testing +test/yacc/err_syntax9.tab.c reference output for testing +test/yacc/err_syntax9.tab.h reference output for testing +test/yacc/error.error reference output for testing +test/yacc/error.output reference output for testing +test/yacc/error.tab.c reference output for testing +test/yacc/error.tab.h reference output for testing +test/yacc/grammar.dot reference output for testing +test/yacc/grammar.error reference output for testing +test/yacc/grammar.output reference output for testing +test/yacc/grammar.tab.c reference output for testing +test/yacc/grammar.tab.h reference output for testing +test/yacc/help.error reference output for testing +test/yacc/help.output reference output for testing +test/yacc/no_b_opt.error reference output for testing +test/yacc/no_b_opt.output reference output for testing +test/yacc/no_b_opt1.error reference output for testing +test/yacc/no_b_opt1.output reference output for testing +test/yacc/no_code_c.error reference output for testing +test/yacc/no_code_c.output reference output for testing +test/yacc/no_defines.error reference output for testing +test/yacc/no_defines.output reference output for testing +test/yacc/no_graph.error reference output for testing +test/yacc/no_graph.output reference output for testing +test/yacc/no_include.error reference output for testing +test/yacc/no_include.output reference output for testing +test/yacc/no_opts.error reference output for testing +test/yacc/no_opts.output reference output for testing +test/yacc/no_output.error reference output for testing +test/yacc/no_output.output reference output for testing +test/yacc/no_output1.error reference output for testing +test/yacc/no_output1.output reference output for testing +test/yacc/no_output2.error reference output for testing +test/yacc/no_output2.output reference output for testing +test/yacc/no_p_opt.error reference output for testing +test/yacc/no_p_opt.output reference output for testing +test/yacc/no_p_opt1.error reference output for testing +test/yacc/no_p_opt1.output reference output for testing +test/yacc/no_verbose.error reference output for testing +test/yacc/no_verbose.output reference output for testing +test/yacc/nostdin.error reference output for testing +test/yacc/nostdin.output reference output for testing +test/yacc/ok_syntax1.error reference output for testing +test/yacc/ok_syntax1.output reference output for testing +test/yacc/ok_syntax1.tab.c reference output for testing +test/yacc/ok_syntax1.tab.h reference output for testing +test/yacc/pure_calc.error reference output for testing +test/yacc/pure_calc.output reference output for testing +test/yacc/pure_calc.tab.c reference output for testing +test/yacc/pure_calc.tab.h reference output for testing +test/yacc/pure_error.error reference output for testing +test/yacc/pure_error.output reference output for testing +test/yacc/pure_error.tab.c reference output for testing +test/yacc/pure_error.tab.h reference output for testing +test/yacc/quote_calc-s.error reference output for testing +test/yacc/quote_calc-s.output reference output for testing +test/yacc/quote_calc-s.tab.c reference output for testing +test/yacc/quote_calc-s.tab.h reference output for testing +test/yacc/quote_calc.error reference output for testing +test/yacc/quote_calc.output reference output for testing +test/yacc/quote_calc.tab.c reference output for testing +test/yacc/quote_calc.tab.h reference output for testing +test/yacc/quote_calc2-s.error reference output for testing +test/yacc/quote_calc2-s.output reference output for testing +test/yacc/quote_calc2-s.tab.c reference output for testing +test/yacc/quote_calc2-s.tab.h reference output for testing +test/yacc/quote_calc2.error reference output for testing +test/yacc/quote_calc2.output reference output for testing +test/yacc/quote_calc2.tab.c reference output for testing +test/yacc/quote_calc2.tab.h reference output for testing +test/yacc/quote_calc3-s.error reference output for testing +test/yacc/quote_calc3-s.output reference output for testing +test/yacc/quote_calc3-s.tab.c reference output for testing +test/yacc/quote_calc3-s.tab.h reference output for testing +test/yacc/quote_calc3.error reference output for testing +test/yacc/quote_calc3.output reference output for testing +test/yacc/quote_calc3.tab.c reference output for testing +test/yacc/quote_calc3.tab.h reference output for testing +test/yacc/quote_calc4-s.error reference output for testing +test/yacc/quote_calc4-s.output reference output for testing +test/yacc/quote_calc4-s.tab.c reference output for testing +test/yacc/quote_calc4-s.tab.h reference output for testing +test/yacc/quote_calc4.error reference output for testing +test/yacc/quote_calc4.output reference output for testing +test/yacc/quote_calc4.tab.c reference output for testing +test/yacc/quote_calc4.tab.h reference output for testing +test/yacc/rename_debug.c reference output for testing +test/yacc/rename_debug.error reference output for testing +test/yacc/rename_debug.h reference output for testing +test/yacc/rename_debug.i reference output for testing +test/yacc/rename_debug.output reference output for testing +test/yacc/varsyntax_calc1.error reference output for testing +test/yacc/varsyntax_calc1.output reference output for testing +test/yacc/varsyntax_calc1.tab.c reference output for testing +test/yacc/varsyntax_calc1.tab.h reference output for testing diff --git a/contrib/byacc/NOTES-btyacc-Changes b/contrib/byacc/NOTES-btyacc-Changes new file mode 100644 index 000000000..f074907ee --- /dev/null +++ b/contrib/byacc/NOTES-btyacc-Changes @@ -0,0 +1,385 @@ +Tom Shields, March 17, 2014 + +PARKING LOT ISSUES: +------------------- +- verify debian packaging still works? + +- there are no #line directives in y.tab.i, other than those that come + from the input file and the skeleton file; to fix this, would need to + count output lines in externs_file and add 'write_externs_lineno()' + similar to 'write_code_lineno()' +- if there are no defined symbols, the .tab.h file isn't empty (weird case, + may not be worth fixing) +- consider: treat []-actions identical to {}-actions if not processing a + backtracking parser (avoids test case error)? + + +BTYACC CHANGES CURRENTLY DEFERRED, BY FILE: +------------------------------------------- + +push.skel +- skeleton for a 'push' parser +- needs to be upgraded match the structure of yaccpar.skel + +defs.h +- adopt '%include' changes +- adopt '%define'/'%ifdef'/'%endif' +- adopt -E flag to print preprocessed grammar to stdout + +error.c +- adopt '%include' changes +- NOTE: there is a btyacc change that might be worth adopting in byacc + [FileError() refactoring to eliminate duplicated code in most of the + error message functions] + +main.c +- adopt '%define' changes +- adopt '-DNAME' command line option to define preprocessor variable NAME +- adopt -E flag to print preprocessed grammar to stdout +- adopt '-S skeleton_file' command line option to select an alternate parser + skeleton file +- the skeleton file named by the -S flag is used as provided to open the + file; consider a change to this behavior to check whether the named file + has a path prefix, and if not, look in 'installation' directory if the + file is not found in the working directory + +output.c +- adopt '%include' changes + +reader.c +- adopt '%include' changes +- adopt '%define'/'%ifdef'/'%endif' changes +- adopt -E flag to print preprocessed grammar to stdout +- NOTE: there is a btyacc change that might be worth adopting in byacc + [copy_string() & copy_comment() refactoring to eliminate duplicated + code in copy_text() and copy_union()] + +warshall.c +- NOTE: there is a btyacc change that might be worth adopting in byacc + [shifting 'mask' incrementally rather than literal '1' by a variable + amount each time thru the loop] + + +================================================================================ + + +new files: +---------- + +skel2c +- modified from btyacc distribution: don't generate #include defs.h +- extended syntax recognized to include '%% insert VERSION here', generating + the defines for YYMAJOR, YYMINOR and YYPATCH at that point +- made generated tables type 'const char *const' to match skelton.c from + byacc-20130925 baseline +- added code to append text for write_section() to end of generated skeleton.c +- remove conversion of tab to \t in generated skeleton.c +- extended syntax recognized to include '%%ifdef', '%%ifndef', '%%else' and + '%%endif'; used in yaccpar.skel to bracket code that is specific to + backtracking + +yaccpar.skel.old +- created from skeleton.c in byacc-20140101 baseline; use of this skeleton + will create a version of skeleton.c that is close to that in the + byacc-20140101 baseline +- eliminated 'body_3' and 'trailer_2' skeleton segments - no need to generate + yyerror() invocation dynamically; YYERROR_CALL() is already generated + earlier, and so can be used in the skeleton to simplify +- added 'const' to types in '%% tables' section to match what skel2c, + start_int_table() and state_str_table() generate +- added a few cosmetic changes (e.g., added some additional comments, + reworded debugging output to match yaccpar.skel, changed yygrowstack() + to return YYENOMEM for 'out of memory' error, rather than -1, to match + yaccpar.skel; changed yyparse() return value from 1 to 2 for the + 'out of memory' error to match yaccpar.skel) +- added '#ifndef'/'#endif' around '#define YYINITSTACKSIZE 200' to allow + the value to be changed at compile time +- changed 'printf(' to 'fprintf(stderr, '; added stack depth (yydepth) to + debugging output from yaccpar.skel +- use 'YYINT' rather than 'short' for integer table types + +yaccpar.skel +- renamed from btyaccpa.ske, merged with btyacc-c.ske +- modified from btyacc distribution to match the latest byacc-20140101 + skeleton structure & data structures +- make local functions static +- change "virtual memory exceeded" to "memory exhausted" for bison + compatibility +- change debug output generation from printf/puts/putc onto stdout to use + fprintf/fputs/fputc onto stderr; include + stack depth and whether or not in trial parsing +- changed types of generated string tables to be 'const pointer to const char' +- check all malloc()/realloc() return values, ensure return value of + yyparse() = 2 if parsing failed due to memory exhaustion +- change YYDBPR() macro to YYSTYPE_TOSTRING(); define semantics as delivering + a char* value representing a semantic value (e.g., yylval or yyval, or the + contents of an entry on the semantic stack); additional parameter passed: + grammar symbol # (to assist interpretation of semantic value) +- change YYPOSN to YYLTYPE and yyposn to yylloc (position corresponding to + yylval) for bison compatibility; add yyloc (corresponding to yyval) +- move default definition of YYLTYPE into output.c, generating a typedef +- add '#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)'/'#endif' around + all lines specific to position processing +- add '#if defined(YYDESTRUCT_CALL)'/'#endif' around all lines specific to + semantic & position stack processing to reclaim memory associated with + discarded symbols +- add '%%ifdef YYBTYACC'/'%%endif' around all lines specific to backtrack + parsing; converted by skel2c into '#if defined(YYBTYACC)'/'#endif' +- distinguish between "yacc stack overflow" and "memory exhausted" situations +- consolidated termination cleanup code; introduced yyreturn, set to 2 after + labels yyoverflow/yyenomem, set to 1 after label yyabort, set to 0 after + label yyaccept; all termination cases jump to label yyreturn, which does + any cleanup then returns yyreturn value +- replaced YYDELETEVAL & YYDELETEPOSN user-supplied macro capability by + implementation of byacc-generated yydestruct() as defined by bison + compatible %destructor mechanism +- moved invocation of 'YYREDUCEPOSNFUNC' macro to immediately prior to, rather + than after, execution of final rule action (so that, at some future + date, implementation extensions can be added to enable custom calculation + of locations associated with non-terminals within rule actions); deleted + unnecessary flag 'reduce_posn'; deleted 'YYCALLREDUCEPOSN' macro; deleted + C++ variant of 'YYREDUCEPOSNFUNC' invocation +- adopt approach similar to bison for default computation of yyloc; change + macro 'YYREDUCEPOSNFUNC' name to 'YYLLOC_DEFAULT' for bison compatibility; + added 'yyerror_loc_range[2]' to hold start & end locations for error + situations that pop the stack +- use 'YYINT' rather than 'short' for integer table types, and for indexing + parser tables + +readskel.c +http://www.verisign.com/index.html- replaced error() with fprintf() + +mstring.h +- moved contents of mstring.h to defs.h - mstring.h is obsolete + +mstring.c +- replaced include of mstring.h with defs.h +- changed 'START' to 'HEAD' to remove conflict with 'START' used for + the start symbol defined in defs.h + +modified byacc files: +--------------------- + +skeleton.c +- skeleton.c is now generated from the appropriate skeleton file by 'skel2c' + +configure.in +- added configuration for --enable-btyacc option; if 'yes' add '-DYYBTYACC' + to DEFINES in makefile.in; --enable-btyacc defaults to 'no' +- added configuration for --with-max-table-size option; if present, + overrides the value of MAXTABLE defined in defs.h +- regenerate configure using autoconf + +makefile.in +- added mstring.c to C_FILES +- added mstring$o to OBJS +- added @DEFINES@ as value of DEFINES make variable +- added new make variable SKELETON with value 'yaccpar.skel' +- added rule to generate skeleton.c from $(SKELETON), depending on skel2c + and makefile +- added rm -f skeleton.c distclean rule +- moved dependency on makefile from only main$o & skeleton$o to $(OBJS), + since if ./configure is run changing, for example, from --enable-btyacc + to --disable-btyacc, all files must be recompiled to ensure a clean + executable +- add @MAXTABLE@ for optional '-DMAXTABLE=nnn' if configured using + --with-max-table-size=nnn +- changed 'cd test && rn 0f test-*'to 'rm -f $(testdir)/test-*' + +test/run_test.sh +- ??? + +test/run_make.sh +- ??? + +defs.h +- moved contents of mstring.h to defs.h - mstring.h is obsolete +- added to get the various system defined machine limits; + changed definitions of MAXCHAR, MAXSHORT, MINSHORT & BITS_PER_WORD to use + defines from ; changed definitions of BIT and SETBIT to use + value of BITS_PER_WORD +- added typedef for __compar_fn_t, conditioned on _COMPAR_FN_T being + undefined (at least for Mac OSX environment) +- adopt new symbol class values ACTION and ARGUMENT +- adopt changes/additions used by inherited attribute processing +- clean up locations of extern function definitions to match where they + actually live in source files +- adopt error functions from inherited attribute processing; added new error + functions +- added keyword code LOCATIONS for %locations +- added keyword code DESTRUCTOR for %destructor +- added extern decl for 'int locations'; true if %locations present +- added extern decl for 'int backtrack'; initialized to 0 (= false), set to + 1 (= true) if -B flag is present +- added extern decl for 'int destructor'; true if at least one %destructor + present in grammar spec file +- define 'YYINT' as the smallest C type that can be used to address a + table of size 'MAXTABLE'; define 'YYINT' based on the value of + 'MAXTABLE' using the standard system type size definitions from ; + define 'MAXYYINT' and 'MINYYINT' accordingly +- change 'Value_t' and 'Index_t' to 'YYINT' from 'short' +- allow 'MAXTABLE' to be defined by '-DMAXTABLE=nnn' at compile-time + +closure.c +- changed print_closure(), print_EFF() and print_first_derives() to 'static'; + added fwd declarations +- changed 'short' to 'Value_t' (in some instances, 'Value_t' was already + used for variables/parameters that were related to variables/parameters + declared as 'short' + +error.c +- adopt error functions from inherited attribute processing; added a few + additional inherited attribute error functions + +graph.c +- changed 'short' to 'Value_t' (in some instances, 'Value_t' was already + used for variables/parameters that were related to variables/parameters + declared as 'short' + +lalr.c +- changed MAXSHORT to MAXYYINT + +lr0.c +- changed MAXSHORT to MAXYYINT +- changed 'short' to 'Value_t' (in some instances, 'Value_t' was already + used for variables/parameters that were related to variables/parameters + declared as 'short' + +main.c +- changed 'short' to 'Value_t' (in some instances, 'Value_t' was already + used for variables/parameters that were related to variables/parameters + declared as 'short' + +mkpar.c +- backtracking attempts to resolve shift/reduce and reduce/reduce conflicts + +output.c +- generate prefix & YYPREFIX defines into externs file (-i, .tab.i) and + code file (-r, .code.c); generate into output file (.tab.c) only if not + using -r option; eliminates doubled output of prefix aliases if -r with + no -i in y.tab.c and y.code.c or if -r & -i in y.tab.i and y.code.c +- changed types of generated string tables to be 'const pointer to const char' +- adopt backtracking as an alternative in cases where otherwise we have a + conflict in the parsing actions (3, rather than 2, choices) +- wrap defines file with (where "yy" is value of 'symbol_prefix') + #ifndef __yy_defines_h_ + #define _yy_defines_h_ + + + + #endif +- avoid writing %%xdecls skeleton section twice if -r used +- eliminated 'body_3' and 'trailer_2' skeleton segments - no need to generate + yyerror() invocation dynamically; YYERROR_CALL() is already generated + earlier, and can be used in the pareser skeleton +- if -P flag (pure_parser), add yylloc as 2nd parameter to yylex() + (declaration & call) +- change YYPOSN to YYLTYPE and yyposn to yylloc (position corresponding to + yylval) for bison compatibility; add yyloc (corresponding to yyval) +- generate yylloc parameters for yylex & yyerror if %locations present +- add location as 1st parameter to declaraion & invocation of yyerror() if + %locations present +- output backtrack parsing tables if -B flag is present +- added generation of yystos[] with output_accessing_symbols() to allow + translation from a parser internal state number to the corresponding + grammar symbol number [0 .. nsyms) of the accessing symbol of that parser + state; used in the generated code for YYDESTRUCT_CALL() & + YYSTYPE_TOSTRING() to enable the correct semantic value union tag to be + determined when executing the implementation of YYDESTRUCT_CALL() or + YYSTYPE_TOSTRING() (similar to yystos[] in bison) +- added to output_prefix(): yystos; yycindex & yyctable if compiling + backtracking; yyloc & yylloc if %locations used +- extended yyname[] to include all grammar symbols, not just the terminal + symbols: '$end', 'error', '$accept', all non-terminals, including internally + generated non-terminals for embedded actions in rules, and 'illegal-symbol' + (which bison spells '$undefined'); '$end' already defined as a symbol 0, + rathern than adding 'end-of-file' as the name of symbol 0; added + 'illegal-symbol' from byacc-20140101 (NOTE: the comment in the code that + says byacc does not predefine '$end' and '$error' is incorrect; however, + both bison and byacc spell '$error' as 'error') +- added generation of #define YYTRANSLATE() from byacc-20140101, but changed + the definition for the undefined symbol case because it is no longer in + yyname[YYMAXTOKEN+1] but rather occurs after the last non-terminal symbol; + added #define YYUNDFTOKEN to contain the index in yyname of 'illegal-symbol' +- generate YYLTYPE in output_ltype() as a struct like for bison rather than + using #define in yaccpar.skel +- added 'write_code_lineno' invocation at start of 'output_prefix' +- added 'write_code_lineno' invocation at start of 'output_pure_parser' +- added 'write_code_lineno' invocation prior to generation of #include + for externs file +- added 'write_code_lineno' invocation after 1st 'write_section(fp, xdecls)' +- added '++outline;' prior to output of '#define YYTRANSLATE' - this was + actually causing almost all of the invocations of 'write_code_lineno' to + put out the correct #line directive +- corrected 'write_code_lineno' - the line number in a #line directive is + the number of the next line, not the number of the #line line +- changed MAXSHORT to MAXYYINT; changed 'high' local static from 'int' to + 'long' so that it can get higher than 'MAXYYINT' without machine-dependent + behavior; changed related formats from '%d' to '%ld' +- generate 'YYINT' rather than 'short' for integer table types +- generate YYDESTRUCT_DECL & YYDESTRUCT_CALL macros, similar to YYERROR_DECL + and YYERROR_CALL macros, that can be redefined by user, if desired, to add + additional parameters to yydestruct() (and even change the 'yydestruct' + function name) +- if at least one %destructor present, generate yydestruct(); 1st parameter + is a string indicating the context in which yydestruct() is invoked + (e.g., discarding input token, discarding state on stack, cleanup when + aborting); 2nd parameter is the internal grammar symbol number [0..nsyms) + of the accessing symbol of the parser state on the top of the stack; 3rd + parameter is a pointer to the semantic value to be reclaimed associated + with the grammar symbol in the 2nd parameter; if %locations is defined, + the 4th parameter is a pointer to the position value to be reclaimed + associated with the grammar symbol in the 2nd parameter + +reader.c +- adopt []-actions, similar to {}-actions; {}-actions are only executed when + not in trial mode, but []-actions are executed regardless of mode +- adopt new symbol class values ACTION and ARGUMENT +- adopt inherited attributes (syntax resembles arguments to non-terminal + symbols) +- adopt keyword table lookup from btyacc, modified to handle equivalence + of '-' and '_' in spelling of keywords +- adopt refactoring of tag table creation into cache_tag() for use in + multiple locations +- added new error functions in place of btyacc's generic error() function +- changed '0' to 'NULL' for pointer initialization +- reworked for-loop at end of get_line (part of DEFERRED '%ifdef/%endif' change) +- added %locations directive for bison compatibility to enable position + processing +- added decl for 'int locations'; true if %locations present +- added decl 'int backtrack'; initialized to 0 (= false), set to + 1 (= true) if -B flag is present +- process %locations if present, set location = 1 +- only process []-actions and only generate 'if (!yytrial)' prefix for + {}-actions if backtracking is enabled +- add decl for 'int destructor'; true if at least one %destructor is present +- add %destructor directive to enable semantic & position stack processing to + reclaim memory associated with discarded symbols +- process bison compatible %destructor (set destructor = 1); support @$ in + %destructor code to reference the position value if %locations is defined +- changed 'short' to 'Value_t' (in some instances, 'Value_t' was already + used for variables/parameters that were related to variables/parameters + declared as 'short' +- if %locations present, support @N and @$ syntax as for bison to reference + the locations associated with the N-th rhs symbol and the lhs symbol, + respectively + +symtab.c +- initialize fields added to 'struct bucket' for non-terminal symbol + inherited attributes + +verbose.c +- for parse states with conflicts, the contents of the y.output file include + the trial shift and/or trial reduce actions +- added output to the end of the verbose report showing the correspondance + between grammar symbol #, internal parser symbol #, and grammar symbol name +- changed 'short' to 'Value_t' (in some instances, 'Value_t' was already + used for variables/parameters that were related to variables/parameters + declared as 'short' + +yacc.1 +- added options 'P', 'V', 'y' and '-o output_file' to the yacc command + synopsis (already covered in the description section) +- added options 'B', 'D' and 'L' to the yacc command synopsis; added text in + the description section +- added %locations description to the extensions section diff --git a/contrib/byacc/NOTES-btyacc-Disposition b/contrib/byacc/NOTES-btyacc-Disposition new file mode 100644 index 000000000..98e527bcc --- /dev/null +++ b/contrib/byacc/NOTES-btyacc-Disposition @@ -0,0 +1,80 @@ +Tom Shields, March 17, 2014 + +NOTE: README.BTYACC needs to be re-written (or another README file created) +to explain how the extensions were adopted into the byacc-20140101 baseline. + +bytacc changes adopted; see README.BTYACC for details. +------------------------------------------------------ + + Changes to the skeleton to send debugging output to stderr. + + Changes to the types of the grammar tables from 'short' to 'int' if +MAXTABLE is defined to be > MAXSHORT for generation of large grammar tables +for large grammars. This can be set with the invocation of configure +using the --with-max-table-size=N option + + Changes to add syntactic sugaring for definition and semantic processing +of inherited attributes associated with non-terminal symbols on the rhs of +rules. Inherited attributes are implemented as {}-actions, and as such may +introduce reduce/reduce conflicts. The advantage over manual {}-actions is +that checking is performed on the number and types of inherited attributes, +and the positions on the semantic stack are automatically calculated. +Identical actions produced by the inherited attribute syntax are collapsed +into a single action, reducing reduce/reduce conflicts. + + The %type specification is extended to define the types of inherited +attributes associated with non-terminal symbols on the lhs of rules, in +addition to its original purpose in yacc for specifying the type of the +symbol itself on the parser's value stack. In order to permit the two + aspects to be used independently, the specification following +%type is optional. + + Added a mechanism to the parser skeleton for computing and propagating +the text position of grammar symbols if %locations directive is present in +the grammar specificaion, or if yacc is invoked with the -L flag. Includes +support for "@$" and "@N" (for N an integer) in actions to refer to symbol +locations. + + Added a bison compatible %destructor directive to define a memory +management mechanism to the parser skeleton that enables cleanup of semantic +values and text positions associated with the parsing stack that are +automatically discarded during error processing. + +The following is only available if configure is invoked with the +--enable-btyacc=yes: + + Changes to enable backtracking with semantic disambiguation, if yacc is +invoked with the -B flag. A yacc parser disambiguates shift/reduce conflicts +by choosing to shift, and reduce/reduce conflicts by reducing using the +earliest grammar rule (in the grammar specification). A btyacc parser handles +a conflict by remembering the current parse point and entering into trial parse +mode. In trial parse mode, the parser tries each of the conflicting options +until the first successs or until all options are exhausted. If the parser +runs into an error while in trial parse mode, it backtracks to the most recent +conflict point and tries the next alternative. If the parser finds a +successful parse, it backtracks to the point where it first entered trial parse +mode and continues with normal parsing, using the action at the start of the +successful trial path. Success in trial parse mode is achieved either by +successfully reducing the start symbol at the end of input or by invocation of +YYVALID (or YYVALID_NESTED). Semantic disambiguation is supported within +[]-actions, which are always executed, with invocation of YYERROR to terminate +a trial path or YYVALID (and YYVALID_NESTED). Yacc {}-actions are only +executed during normal parsing. + + +btyacc changes deferred: +------------------------ + + The -S command line flag to enable use of an alternate parser skeleton, +read from an external file. + + Preprocessor statements: %define, %ifdef/%endif, %include. + + +btyacc changes rejected: +------------------------ + + The yyerror_detailed() option for error messages is replaced by the +byacc feature for specifying options paramters to yyerror(). + + C++-specific features in the parser skeleton. diff --git a/contrib/byacc/README.BTYACC b/contrib/byacc/README.BTYACC new file mode 100644 index 000000000..e617ec2e7 --- /dev/null +++ b/contrib/byacc/README.BTYACC @@ -0,0 +1,617 @@ +-- $Id: README.BTYACC,v 1.2 2014/04/22 08:18:57 Tom.Shields Exp $ + +The original README from btyacc is below. + +The backtracking enhancements to byacc have been merged into Thomas Dickey's +byacc baseline. + +The %include and %define/%ifdef enhancements described below are not currently +incorporated. + +The position management functionality ("YYPOSN", "yyposn", "YYREDUCEPOSNFUNC", +"YYREDUCEPOSNFUNCARG" & "YYCALLREDUCEPOSN") is replaced by a bison-compatible +"%locations" implementation. + +The memory management functionality ("YYDELETEVAL" & "YYDELETEPOSN") is +replaced by a bison-compatible "%destructor" implementation. + +The detailed syntax error processing functionality ("YYERROR_DETAILED" +& "yyerror_detailed()") is subsumed by the bison-compatible "yyerror()" +implementation, as modified by the %parse-param and %locations directives. + +The debugging macro "YYDBPR()" in the parser skeleton is renamed +"YYSTYPE_TOSTRING()". + +------------------------------------------------------------------------------- + BTYACC -- backtracking yacc + =========================== + +BTYACC was created by Chris Dodd using ideas from many +places and lots of code from the Berkeley Yacc +distribution, which is a public domain yacc clone put +together by the good folks at Berkeley. This code is +distributed with NO WARRANTY and is public domain. +It is certain to contain bugs, which you should +report to: chrisd@collins.com. + +Vadim Maslov of Siber Systems +considerably modified BTYACC to make it suitable +for production environment. + +Several people have suggested bug fixes that +were incorporated into BtYacc. + +See the README.BYACC files for more about +Berkeley Yacc and other sources of info. + +http://www.siber.com/btyacc/ is the current home of BtYacc. +It is provided courtesy of Siber Systems http://www.siber.com/. + + + Version 3.0 changes + ------------------- + by Vadim Maslov + +Changes mostly occurred in btyaccpa.ske file that +contains the parsing shift/reduce/backtrack algorithm. + +Version 3.0 innovations focus on: +- text position computation and propagation, +- industrial-strength error processing and recovery. + + +** Added mechanism for computing and propagating +text position of tokens and non-terminals. + +Compilers often need to build AST trees such that every node +in a tree can relate to the parsed program source it came from. +The following applications are very likely to need this: +- debuggers that show actual source of the debugged program, +- source-to-source translators that want + unchanged parts of the tree to generate the unchanged code. + +The new YYPOSN mechanism added in this version of BtYacc +helps you in automating the text position computation +and in assigning the computed text positions to the AST. +This mechanism is successfully used in commercial +parsers and source-to-source translators. + +In standard Yaccs every token and every non-terminal +has an YYSTYPE semantic value attached to it. +In this new version every token and every non-terminal +also has an YYPOSN text position attached to it. +YYPOSN is a user-defined type that can be anything and +that has a meaning of text position attached to +token or non-terminal. + +In addition to semantic value stack BtYacc now maintains +text position stack. Behavior of the text position stack +is similar to the behavior of the semantic value stack. + +If using text position mechanism, +you need to define the following: + +YYPOSN Preprocessor variable that contains C/C++ type of + the text position attached to + every token and non-terminal. + +yyposn Global variable of type YYPOSN. + The lexer must assign text position of + the returned token to yyposn, just like it assigns + semantic value of the returned token to yylval. + +YYREDUCEPOSNFUNC + Preprocessor variable that points to function that + is called after the grammar rule reduction + to reduce text positions located on the stack. + + This function is called by BtYacc to reduce text + positions. The function is called immediately after + the regular rule reduction occurs. + + The function has the following prototype: + void ReducePosn(YYPOSN &ret, + YYPOSN *terms, + YYSTYPE *term_vals, + int term_no, + int stk_pos, + int yychar, + YYPOSN &yyposn, + UserType extra); + + The function arguments are: + - ret + Reference to the text position returned by + the rule. The function must write the computed + text position returned by the rule to ret. + This is analogue of the $$ semantic value. + + - term_posns + Array of the right-hand side rule components + YYPOSN text positions. These are analogues of + $1, $2, ..., $N in the text position world. + + - term_vals + Array of the right-hand side (RHS) rule components + YYSTYPE values. These are the $1,...,$N themselves. + + - term_no + Number of the components in RHS of the reduced rule. + Equal to size of arrays term_posns and term_vals. + Also equal to N in $1,...,$N in the reduced rule. + + - stk_pos + YYSTYPE/YYPOSN stack position before the reduction. + + - yychar + Lookahead token that immediately follows + the reduced RHS components. + + - yyposn + YYPOSN of the token that immediately follows + the reduced RHS components. + + - extra + User-defined extra argument passed to ReducePosn. + + Typically this function extracts text positions from + the right-hand side rule components and either + assigns them to the returned $$ structure/tree or + if no $$ value is returned, puts them into + the ret text position from where + it will be picked up by the later reduced rules. + +YYREDUCEPOSNFUNCARG + Extra user-defined argument passed to + the ReducePosn function. This argument can use + any variables defined in btyaccpa.ske. + + +** Added code to btyaccpa.ske that automatically cleans up +semantic semantic values and text positions of tokens +and non-terminals that are discarded and deleted as +a result of error processing. + +In the previous versions the discarded token and non-terminal +semantic values were not cleaned that caused quite severe +leaks. The only way to fix it was to add garbage collection +to YYSTYPE class. + +Now BtYacc skeleton calls delete functions for semantic +values and positions of the discarded tokens and +non-terminals. + +You need to define the following functions that BtYacc +calls when it needs to delete semantic value or text position. + +YYDELETEVAL + User-defined function that is called by BtYacc + to delete semantic value of the token or non-terminal. + + The user-defined function must have the prototype: + void DeleteYYval(YYSTYPE v, int type); + v is semantic value to delete, + type is one of the following: + 0 discarding token + 1 discarding state + 2 cleaning up stack when aborting + +YYDELETEPOSN + User-defined function that is called by BtYacc + to delete text position of the token or non-terminal. + + The user-defined function must have the prototype: + void DeleteYYposn(YYPOSN p, int type); + v is semantic value to delete, + type is one of the following: + 0 discarding token + 1 discarding state + 2 cleaning up stack when aborting + + +** User can define "detailed" syntax error processing +function that reports an *exact* position of +the token that caused the error. + +If you define preprocessor variable YYERROR_DETAILED in +your grammar then you need define the following +error processing function: + +void yyerror_detailed(char *text, + int errt, + YYSTYPE &errt_value, + YYPOSN &errt_posn); + +It receives the following arguments: +text Error message. +errt Code of the token that caused the error. +errt_value Value of the token that caused the error. +errt_posn Text position of token that caused error. + + +** Dropped compatibility with C. + +Compatibility with C became increasingly difficult +to maintain as new features were added to btyaccpa.ske. +So we dropped it. If anybody wants to make the new version +compatible with C, we would gladly accept the changes. + +Meanwhile we expect that you use C++ to write grammar +actions and everything else in grammar files. +Since C is (in a sense) subset of C++, your C-based +grammar may work if you use C++ compiler to compile it. + + Version 3.0 bugs fixed + ---------------------- + +Matthias Meixner fixed a bug: +BtYacc does not correctly handle typenames, if one typename +is a prefix of another one and if this type is used after +the longer one. In this case BTYacc produces invalid code. + + + Version 2.1 changes + ------------------- + by Vadim Maslov + +** Added preprocessor statements to BtYacc that are similar +in function and behavior to C/C++ preprocessor statements. + +These statements are used to: + +- Introduce modularity into a grammar by breaking it + into several *.y files and assembling different + grammars from the *.y modules using %include and %ifdef. + +- Have several versions of the same grammar + by using %ifdef and $endif. + +- To include automatically generated grammar fragment. + For instance, we use %include to include + automatically generated list of tokens. + +Preprocessor statements are: + +%define + Define preprocessor variable named . + +%ifdef + If preprocessor variable named + is defined by %define, then process the text from + this %ifdef to the closing %endif. + +%endif + Closing bracket for %ifdef preprocessor statement. + Only one nesting level of %ifdef-%endif is allowed. + +%include + Process contents of the file named . + If is a relative name, it is looked up + in a directory in which btyacc was started. + Only one nesting level of %include is allowed. + + + Version 2.0 changes + ------------------- + by Vadim Maslov + + +** Changed 16-bit short numbers to 32-bit int numbers in +grammar tables, so that huge grammar tables (tables that +are larger than 32768 elements) resulting from huge +grammars (Cobol grammar, for instance) can work correctly. +You need to have 32-bit integer to index table bigger than +32768 elements, 16-bit integer is not enough. + +The original BtYacc just generated non-working tables +larger than 32768 elements without even notifying about +the table overflow. + + +** Make error recovery work correctly when error happens +while processing nested conflicts. Original BtYacc could +infinitely cycle in certain situations that involved error +recovery while in nested conflict. + +More detailed explanation: when we have nested conflicts +(conflict that happens while trial-processing another +conflict), it leads btyacc into NP-complete searching of +conflict tree. The ultimate goal is YYVALID operator that +selects a particular branch of that tree as a valid one. + +If no YYVALID is found on the tree, then error recovery +takes over. The problem with this is that error recovery +is started in the same state context that exists on the +last surveyed branch of the conflict tree. Sometimes this +last branch may be of zero length and it results in +recovering to exactly the same state as existed before +entering the conflict. BtYacc cycles then. + +We solved this problem by memorizing the longest path in +the conflict tree while browsing it. If we ever get into +error recovery, we restore state that existed on the +longest path. Effectively we say: if we have an error, +let us move forward as far as we possibly could while we +were browsing the conflict tree. + + +** Introduce YYVALID_NESTED operation in addition to +simply YYVALID. When we have a nested conflict (conflict +while processing in trial mode for another conflict), we +want to relate YYVALID to a particular level of conflict +being in trial. + +Since we mostly anticipate only 2-level nested conflicts +YYVALID_NESTED tells the parser to satisfy only the +internal conflict. Therefore, in 1-level conflict +situation YYVALID_NESTED acts like a regular YYVALID, but +in 2-level conflict it is a no-op and the other YYVALID +for outer conflict will be searched for. + + +** Improved handling of situation where /tmp directory is +missing. Original btyacc just died quietly when /tmp +directory was missing. We added code that states the +problem explicitly. While on UNIX /tmp directory is always +present, it may be missing on WIN32 systems, therefore +diagnosing this situation is important. + + + Version 1.0 changes: BackTracking + ================================= + by Chris Dodd + +BTYACC is a modified version of yacc that supports +automatic backtracking and semantic disambiguation to +parse ambiguous grammars, as well as syntactic sugar for +inherited attributes (which tend to introduce conflicts). +Whenever a btyacc generated parser runs into a +shift-reduce or reduce-reduce error in the parse table, it +remembers the current parse point (yacc stack and input +stream state), and goes into trial parse mode. It then +continues parsing, ignoring most rule actions. If it runs +into an error (either through the parse table or through +an action calling YYERROR), it backtracks to the most +recent conflict point and tries a different alternative. +If it finds a successful parse (reaches the end of the +input or an action calls YYVALID), it backtracks to the +point where it first entered trial parse mode, and +continues with a full parse (executing all actions), +following the path of the successful trial. + +Actions in btyacc come in two flavors -- {}-actions, which +are only executed when not in trial mode, and []-actions +which are executed regardless of mode. There are also +inherited attributes, which look like arguments (they are +enclosed in "()") and act like []-actions. + +What this buys you: + +* No more lexer feedback hack. In yacc grammars for C, a +standard hack, know as the "lexer feedback hack" is used +to find typedef names. The lexer uses semantic +information to decide if any given identifier is a +typedef-name or not and returns a special token. With +btyacc, you no longer need to do this; the lexer should +just always return an identifier. The btyacc grammar then +needs a rule of the form: + +typename: ID [ if (!IsTypeName(LookupId($1))) YYERROR; ] + +While the hack works adequately well for parsing C, it +becomes a nightmare when you try to parse something like +C++, where treating an ID as a typedef becomes heavily +dependent on context. + +* Easy disambiguation via simple ordering. Btyacc runs +its trials via the rule "try shifting first, then try +reducing by the order that the conflicting rules appear in +the input file". This means you can deal with semantic a +disambiguation rule like: + [1] If it looks like a declaration it is, otherwise + [2] If it looks like an expression it is, otherwise + [3] it is a syntax error + [Ellis&Stroustrup, Annotated C++ Reference Manual, p93] + +To deal with this, you need only put all the rules for +declarations before the rules for expressions in the +grammar file. + +* No extra cost if you do not use it. Backtracking is +only triggered when the parse hits a shift/reduce or +reduce/reduce conflict in the table. If you have no +conflicts in your grammar, there is no extra cost, other +than some extra code which will never be invoked. + +* C++ and ANSI C compatible parsers. The parsers produced +by btyacc can be compiled with C++ correctly. If you +"#define" YYSTYPE to be some C++ type with constructor and +destructor, everything will work fine. My favorite is +"#define YYSTYPE SmartPointer", where SmartPointer is a +smart pointer type that does garbage collection on the +pointed to objects. + +BTYACC was originally written to make it easy to write a +C++ parser (my goal was to be able to use the grammar out +of the back of the ARM with as few modifications as +possible). Anyone who has ever looked at Jim Roskind +public domain C++ yacc grammar, or the yacc-based grammar +used in g++ knows how difficult this is. BTYACC is very +useful for parsing any ambiguous grammar, particularly +ones that come from trying to merge two (or more) complete +grammars. + +Limitations of the backtracking: Currently, the generated +parser does NO pruning of alternate parsing paths. To +avoid an exponential explosion of possible paths (and +parsing time), you need to manually tell the parser when +it can throw away saved paths using YYVALID. In practice, +this turns out to be fairly easy to do. A C++ parser (for +example) can just put a [YYVALID;] after every complete +declaration and statement rule, corresponding to pruning +the backtracking state after seeing a ';' or '}' -- there +will never be a situation in which it is useful to +backtrack past either of these. + +Inherited attributes in btyacc: + +Inherited attributes look a lot like function arguments to +non-terminals, which is what they end up being in a +recursive descent parser, but NOT how they are implemented +in btyacc. Basically they are just syntactic sugar for +embedded semantic actions and $0, $-1, ... in normal yacc. +btyacc gives you two big advantages besides just the +syntax: + 1. it does type checking on the inherited attributes, + so you do not have to specify $0 and makes sure + you give the correct number of arguments (inherited + attributes) to every use of a non-terminal. + 2. It "collapses" identical actions from that are produced + from inherited attributes. This eliminates many + potential reduce-reduce conflicts arising from + the inherited attributes. + +You use inherited attributes by declaring the types of the +attributes in the preamble with a type declaration and +declaring names of the attributes on the lhs of the yacc +rule. You can of course have more than one rule with the +same lhs, and you can even give them different names in +each, but the type and number must be the same. + +Here is a small example: + /* lhs takes 2 inherited attributes */ +%type lhs(, ) + stuff(, ) +%% +lhs($i1, $i2) : { $$ = $i1 } + | lhs($i1, $i2) stuff($1,$i2) { $$ = $2; } + +This is roughly equivalent to the following yacc code: +lhs : + { $$ = $-1; } + | lhs [ $$ = $-1; ] [ $$ = $0; ] stuff + { $$ = $4; } + ; + +See the file "test/t2.y" for a longer and more complete +example. At the current time, the start symbol cannot +have any arguments. + +Variant parsers: + +Btyacc supports the -S flag to use a different parser +skeleton, changing the way that the parser is called and +used. The skeleton "push.skel" is included to produce a +"passive" parser that you feed tokens to (rather than +having the parser call a separate yylex routine). With +push.skel, yyparse is defined as follows: + +int yyparse(int token, YYSTYPE yylval) + +You should call yyparse repeatedly with successive tokens +of input. It returns 0 if more input is needed, 1 for a +successful parse, and -1 for an unrecoverable parse error. + + + Miscellaneous Features in ver. 1.0 + ---------------------------------- + by Chris Dodd + + The -r option has been implemented. The -r option tells +Yacc to put the read-only tables in y.tab.c and the code and +variables in y.code.c. Keith Bostic asked for this option so +that :yyfix could be eliminated. + + The -l and -t options have been implemented. The -l +option tells Yacc not to include #line directives in the code +it produces. The -t option causes debugging code to be +included in the compiled parser. + + The code for error recovery has been changed to +implement the same algorithm as AT&T Yacc. There will still +be differences in the way error recovery works because AT&T +Yacc uses more default reductions than Berkeley Yacc. + + The environment variable TMPDIR determines the directory +where temporary files will be created. If TMPDIR is defined, +temporary files will be created in the directory whose +pathname is the value of TMPDIR. By default, temporary files +are created in /tmp. + + The keywords are now case-insensitive. For example, +%nonassoc, %NONASSOC, %NonAssoc, and %nOnAsSoC are +all equivalent. + + Commas and semicolons that are not part of C code are +treated as commentary. + + Line-end comments, as in BCPL, are permitted. Line-end +comments begin with // and end at the next end-of-line. +Line-end comments are permitted in C code; they are converted +to C comments on output. + + The form of y.output files has been changed to look more +like those produced by AT&T Yacc. + + A new kind of declaration has been added. +The form of the declaration is + + %ident string + +where string is a sequence of characters beginning with a +double quote and ending with either a double quote or the +next end-of-line, whichever comes first. The declaration +will cause a #ident directive to be written near the start +of the output file. + + If a parser has been compiled with debugging code, that +code can be enabled by setting an environment variable. +If the environment variable YYDEBUG is set to 0, debugging +output is suppressed. If it is set to 1, debugging output +is written to standard output. + + + Building BtYacc + --------------- + by Chris Dodd and Vadim Maslov + +We used GCC and GNU make to compile BtYacc both on UNIX and +WIN32 paltforms. You are welcome to try different +combinations of makes and compilers. Most likely it will +work, but it may require Makefile changes. + +There is no config script. +Just type "make" and it should compile. + +AWK. If you want to change file btyaccpa.ske (backtracking +parser skeleton), you will need awk to compile it into +skeleton.c file. We used GNU AWK (gawk) version 3.0. + +It is known that using older versions of gawk +may create problems in compilation, because older awks +have problems with backslashes at the end of a line. + +For MSDOS, there a "makefile.dos" that should do the trick. +Note: makefile.dos was not tested for a long time. + +The result of compilation should be a single executable called +"btyacc" which you can install anywhere you like; +it does not require any other files in the distribution to run. + + + Legal Stuff + ----------- + by Chris Dodd and Vadim Maslov + +In English: BtYacc is freeware. BtYacc is distributed with +no warranty whatsoever. The author and any other contributors +take no responsibility for any and all consequences of its use. + +In Legalese: LIMITATION OF LIABILITY. NEITHER SIBER SYSTEMS +NOR ANY OF ITS LICENSORS NOR ANY BTYACC CONTRIBUTOR SHALL BE +LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL +DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR +DATA USE, CAUSED BY BTYACC AND INCURRED BY CUSTOMER OR ANY +THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, EVEN +IF SIBER SYSTEMS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. diff --git a/contrib/byacc/VERSION b/contrib/byacc/VERSION index 9107e3f1f..50894d115 100644 --- a/contrib/byacc/VERSION +++ b/contrib/byacc/VERSION @@ -1 +1 @@ -20130304 +20140422 diff --git a/contrib/byacc/aclocal.m4 b/contrib/byacc/aclocal.m4 index 0741516f0..5283b2e53 100644 --- a/contrib/byacc/aclocal.m4 +++ b/contrib/byacc/aclocal.m4 @@ -1,7 +1,7 @@ -dnl $Id: aclocal.m4,v 1.30 2013/03/05 01:13:39 tom Exp $ +dnl $Id: aclocal.m4,v 1.34 2014/04/06 19:16:18 tom Exp $ dnl Macros for byacc configure script (Thomas E. Dickey) dnl --------------------------------------------------------------------------- -dnl Copyright 2004-2012,2013 Thomas E. Dickey +dnl Copyright 2004-2013,2014 Thomas E. Dickey dnl dnl Permission is hereby granted, free of charge, to any person obtaining a dnl copy of this software and associated documentation files (the @@ -232,7 +232,7 @@ if test ".$system_name" != ".$cf_cv_system_name" ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_CLANG_COMPILER version: 1 updated: 2012/06/16 14:55:39 +dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35 dnl ----------------- dnl Check if the given compiler is really clang. clang's C driver defines dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does @@ -243,7 +243,7 @@ dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from dnl the wrappers for gcc and g++ warnings. dnl dnl $1 = GCC (default) or GXX -dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS +dnl $2 = CLANG_COMPILER (default) dnl $3 = CFLAGS (default) or CXXFLAGS AC_DEFUN([CF_CLANG_COMPILER],[ ifelse([$2],,CLANG_COMPILER,[$2])=no @@ -449,7 +449,7 @@ if test "$GCC" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_GCC_WARNINGS version: 29 updated: 2012/06/16 14:55:39 +dnl CF_GCC_WARNINGS version: 31 updated: 2013/11/19 19:23:35 dnl --------------- dnl Check if the compiler supports useful warning options. There's a few that dnl we don't use, simply because they're too noisy: @@ -521,10 +521,14 @@ then EXTRA_CFLAGS= cf_warn_CONST="" test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings" + cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs" + test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings= for cf_opt in W Wall \ Wbad-function-cast \ Wcast-align \ Wcast-qual \ + Wdeclaration-after-statement \ + Wextra \ Winline \ Wmissing-declarations \ Wmissing-prototypes \ @@ -532,7 +536,7 @@ then Wpointer-arith \ Wshadow \ Wstrict-prototypes \ - Wundef $cf_warn_CONST $1 + Wundef $cf_gcc_warnings $cf_warn_CONST $1 do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" if AC_TRY_EVAL(ac_compile); then @@ -596,7 +600,7 @@ make an error test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" ])dnl dnl --------------------------------------------------------------------------- -dnl CF_INTEL_COMPILER version: 5 updated: 2013/02/10 10:41:05 +dnl CF_INTEL_COMPILER version: 6 updated: 2014/03/17 13:13:07 dnl ----------------- dnl Check if the given compiler is really the Intel compiler for Linux. It dnl tries to imitate gcc, but does not return an error when it finds a mismatch @@ -625,7 +629,7 @@ if test "$ifelse([$1],,[$1],GCC)" = yes ; then make an error #endif ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes -cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc" +cf_save_CFLAGS="$cf_save_CFLAGS -we147" ],[]) ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2])) @@ -634,6 +638,60 @@ cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc" fi ])dnl dnl --------------------------------------------------------------------------- +dnl CF_MAKE_DOCS version: 3 updated: 2014/01/05 13:21:25 +dnl ------------ +dnl $1 = name(s) to generate rules for +dnl $2 = suffix of corresponding manpages used as input. +define([CF_MAKE_DOCS],[ +test -z "$cf_make_docs" && cf_make_docs=0 + +cf_output=makefile +test -f "$cf_output" || cf_output=Makefile + +if test "$cf_make_docs" = 0 +then +cat >>$cf_output <<"CF_EOF" +################################################################################ +.SUFFIXES : .html .$2 .man .ps .pdf .txt + +.$2.html : + GROFF_NO_SGR=stupid [$](SHELL) -c "tbl [$]*.$2 | groff -P -o0 -I$*_ -Thtml -man" >[$]@ + +.$2.ps : + [$](SHELL) -c "tbl [$]*.$2 | groff -man" >[$]@ + +.$2.txt : + GROFF_NO_SGR=stupid [$](SHELL) -c "tbl [$]*.$2 | nroff -Tascii -man | col -bx" >[$]@ + +.ps.pdf : + ps2pdf [$]*.ps + +CF_EOF + cf_make_docs=1 +fi + +for cf_name in $1 +do +cat >>$cf_output <save)", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + "", + "#if YYDEBUG", + "#include /* needed for printf */", + "#endif", + "", + "#include /* needed for malloc, etc */", + "#include /* 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 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 = (short *)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 defined(YYBTYACC) + "#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 = (short *) malloc(size * sizeof(short));", + " 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 */", +#endif /* defined(YYBTYACC) */ + "", + "#define YYABORT goto yyabort", + "#define YYREJECT goto yyabort", + "#define YYACCEPT goto yyaccept", + "#define YYERROR goto yyerrlab", +#if defined(YYBTYACC) + "#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 */", +#endif /* defined(YYBTYACC) */ + "", + "int", + "YYPARSE_DECL()", + "{", + 0 +}; + +const char *const body_2[] = +{ + " int yym, yyn, yystate, yyresult;", +#if defined(YYBTYACC) + "#if YYBTYACC", + " int yynewerrflag;", + " YYParseState *yyerrctx = NULL;", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", + " YYLTYPE yyerror_loc_range[2]; /* position of error start & end */", + "#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(YYBTYACC) + "#if YYBTYACC", + " yyps = yyNewState(0); if (yyps == 0) goto yyenomem;", + " yyps->save = 0;", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + " 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 defined(YYBTYACC) + "#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 */", + " int p = yylvp - yylvals;", + " int s = 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 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 = (short) 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 */", +#endif /* defined(YYBTYACC) */ + " yychar = YYLEX;", +#if defined(YYBTYACC) + "#if YYBTYACC", + " } while (0);", + "#endif /* YYBTYACC */", +#endif /* defined(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 token %d (%s)\",", + " YYDEBUGSTR, yydepth, yystate, yychar, yys);", + "#ifdef YYSTYPE_TOSTRING", +#if defined(YYBTYACC) + "#if YYBTYACC", + " if (!yytrial)", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + " fprintf(stderr, \" <%s>\", YYSTYPE_TOSTRING(yychar, yylval));", + "#endif", + " fputc('\\n', stderr);", + " }", + "#endif", + " }", +#if defined(YYBTYACC) + "#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));", + " 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));", + "#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));", + "#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));", + " 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 = (short) yychar;", + " yychar = YYEMPTY;", + " }", + " }", + " }", + " if (yychar >= YYEOF)", + " {", + " yylvp--;", + "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", + " yylpp--;", + "#endif", + " yylexp--;", + " yychar = YYEMPTY;", + " }", + " save->lexeme = 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 = (short) 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 */", +#endif /* defined(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 defined(YYBTYACC) + "#if YYBTYACC", + "", + " yynewerrflag = 1;", + " goto yyerrhandler;", + " goto yyerrlab;", + "", + "yyerrlab:", + " 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));", + " 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));", + "#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));", + "#endif", + " yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));", + " 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));", + "#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));", + "#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));", + " 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));", + "#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));", + "#endif", + " yystate = yyerrctx->state;", + " yyFreeState(yyerrctx);", + " yyerrctx = NULL;", + " }", + " yynewerrflag = 1;", + " }", + " if (yynewerrflag == 0) goto yyinrecovery;", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + "", + " YYERROR_CALL(\"syntax error\");", + "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", + " yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */", + "#endif", + "", + "#if !YYBTYACC", + " goto yyerrlab;", + "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[1] = 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[0] = *yystack.p_mark;", + "#endif", + "#if defined(YYDESTRUCT_CALL)", +#if defined(YYBTYACC) + "#if YYBTYACC", + " if (!yytrial)", + "#endif /* YYBTYACC */", +#endif /* defined(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)", + " {", + " yys = yyname[YYTRANSLATE(yychar)];", + " fprintf(stderr, \"%s[%d]: state %d, error recovery discarding token %d (%s)\\n\",", + " YYDEBUGSTR, yydepth, yystate, yychar, yys);", + " }", + "#endif", + "#if defined(YYDESTRUCT_CALL)", +#if defined(YYBTYACC) + "#if YYBTYACC", + " if (!yytrial)", + "#endif /* YYBTYACC */", +#endif /* defined(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 defined(YYBTYACC) + "#if YYBTYACC", + " if (!yytrial)", + "#endif /* YYBTYACC */", +#endif /* defined(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 defined(YYBTYACC) + "#if YYBTYACC", + " if (!yytrial)", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + " {", + " YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-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];", + " }", + "#endif", + "", + " switch (yyn)", + " {", + 0 +}; + +const char *const trailer[] = +{ + " 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 defined(YYBTYACC) + "#if YYBTYACC", + " if (!yytrial)", + "#endif /* YYBTYACC */", +#endif /* defined(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 defined(YYBTYACC) + "#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 */", + " int p = yylvp - yylvals;", + " int s = 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 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 = (short) 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 */", +#endif /* defined(YYBTYACC) */ + " yychar = YYLEX;", +#if defined(YYBTYACC) + "#if YYBTYACC", + " } while (0);", + "#endif /* YYBTYACC */", +#endif /* defined(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\",", + " 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 defined(YYBTYACC) + "#if YYBTYACC", + " if (!yytrial)", + "#endif /* YYBTYACC */", +#endif /* defined(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 = (short) yystate;", + " *++yystack.l_mark = yyval;", + "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", + " *++yystack.p_mark = yyloc;", + "#endif", + " goto yyloop;", +#if defined(YYBTYACC) + "#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));", + " 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));", + "#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));", + "#endif", + " yystate = yypath->state;", + " goto yyloop;", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + "", + "yyoverflow:", + " YYERROR_CALL(\"yacc stack overflow\");", +#if defined(YYBTYACC) + "#if YYBTYACC", + " goto yyabort_nomem;", + "yyenomem:", + " YYERROR_CALL(\"memory exhausted\");", + "yyabort_nomem:", + "#endif /* YYBTYACC */", +#endif /* defined(YYBTYACC) */ + " yyresult = 2;", + " goto yyreturn;", + "", + "yyabort:", + " yyresult = 1;", + " goto yyreturn;", + "", + "yyaccept:", +#if defined(YYBTYACC) + "#if YYBTYACC", + " if (yyps->save) goto yyvalid;", + "#endif /* YYBTYACC */", +#endif /* defined(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 defined(YYBTYACC) + "#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 */", +#endif /* defined(YYBTYACC) */ + " yyfreestack(&yystack);", + " return (yyresult);", + "}", + 0 +}; + +void +write_section(FILE * fp, const char *const section[]) +{ + int i; + const char *s; + + for (i = 0; (s = section[i]) != 0; ++i) + { + if (fp == code_file) + ++outline; + fprintf(fp, "%s\n", s); + } +} diff --git a/contrib/byacc/btyaccpar.skel b/contrib/byacc/btyaccpar.skel new file mode 100644 index 000000000..265be42c0 --- /dev/null +++ b/contrib/byacc/btyaccpar.skel @@ -0,0 +1,1125 @@ +/* $Id: btyaccpar.skel,v 1.1 2014/04/02 22:44:41 tom Exp $ */ + +#include "defs.h" + +/* If the skeleton is changed, the banner should be changed so that */ +/* the altered version can be easily distinguished from the original. */ +/* */ +/* The #defines included with the banner are there because they are */ +/* useful in subsequent code. The macros #defined in the header or */ +/* the body either are not useful outside of semantic actions or */ +/* are conditional. */ + +%% banner +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +%% insert VERSION here + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +%% xdecls + +extern int YYPARSE_DECL(); +%% tables +extern const YYINT yylhs[]; +extern const YYINT yylen[]; +extern const YYINT yydefred[]; +extern const YYINT yystos[]; +extern const YYINT yydgoto[]; +extern const YYINT yysindex[]; +extern const YYINT yyrindex[]; +%%ifdef YYBTYACC +extern const YYINT yycindex[]; +%%endif +extern const YYINT yygindex[]; +extern const YYINT yytable[]; +extern const YYINT yycheck[]; +%%ifdef YYBTYACC +extern const YYINT yyctable[]; +%%endif + +#if YYDEBUG +extern const char *const yyname[]; +extern const char *const yyrule[]; +#endif +%% global_vars + +int yydebug; +int yynerrs; +%% impure_vars + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif +%% hdr_defs + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +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; \ + } \ + 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; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +%%ifdef YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +%%endif + +/* 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; + short *s_base; + short *s_mark; + short *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +%%ifdef 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 +%% hdr_vars +/* variables for the parser stack */ +static YYSTACKDATA yystack; +%%ifdef 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 short *yylexp = 0; + +static short *yylexemes = 0; +%%endif YYBTYACC +%% body_vars + int yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* variables for the parser stack */ + YYSTACKDATA yystack; +%%ifdef 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 short *yylexp = 0; + + static short *yylexemes = 0; +%%endif YYBTYACC +%% body_1 + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +%%ifdef YYBTYACC +#define yytrial (yyps->save) +%%endif + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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) */ +%%ifdef 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 = (short *) malloc(size * sizeof(short)); + 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 +%%ifdef 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 + +int +YYPARSE_DECL() +{ +%% body_2 + int yym, yyn, yystate, yyresult; +%%ifdef YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +%%endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ +#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 + +%%ifdef YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 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) == 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) + { +%%ifdef 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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; +%%ifdef YYBTYACC + } while (0); +%%endif + 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 token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +%%ifdef YYBTYACC + if (!yytrial) +%%endif + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +%%ifdef 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; +%%ifdef YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +%%ifdef YYBTYACC + if (!yytrial) +%%endif +#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) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +%%ifdef YYBTYACC + if (!yytrial) +%%endif +#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 +%%ifdef YYBTYACC + if (!yytrial) +%%endif + 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)); +%%ifdef YYBTYACC + if (!yytrial) +%%endif + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-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]; + } +#endif + + switch (yyn) + { +%% trailer + 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 +%%ifdef YYBTYACC + if (!yytrial) +%%endif + 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) + { +%%ifdef 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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; +%%ifdef YYBTYACC + } while (0); +%%endif + 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", + 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 +%%ifdef YYBTYACC + if (!yytrial) +%%endif + 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 = (short) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +%%ifdef 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yystate = yypath->state; + goto yyloop; +%%endif YYBTYACC + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +%%ifdef YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +%%endif + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +%%ifdef YYBTYACC + if (yyps->save) goto yyvalid; +%%endif + 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) */ + +%%ifdef 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/contrib/byacc/closure.c b/contrib/byacc/closure.c index 7573ff5bb..76003c0aa 100644 --- a/contrib/byacc/closure.c +++ b/contrib/byacc/closure.c @@ -1,4 +1,4 @@ -/* $Id: closure.c,v 1.9 2010/06/09 08:21:47 tom Exp $ */ +/* $Id: closure.c,v 1.10 2014/02/19 00:45:42 Tom.Shields Exp $ */ #include "defs.h" @@ -9,12 +9,18 @@ unsigned *ruleset; static unsigned *first_derives; static unsigned *EFF; +#ifdef DEBUG +static void print_closure(int); +static void print_EFF(void); +static void print_first_derives(void); +#endif + static void set_EFF(void) { unsigned *row; int symbol; - short *sp; + Value_t *sp; int rowsize; int i; int rule; @@ -53,7 +59,7 @@ set_first_derives(void) int j; unsigned k; unsigned cword = 0; - short *rp; + Value_t *rp; int rule; int i; @@ -100,7 +106,7 @@ set_first_derives(void) } void -closure(short *nucleus, int n) +closure(Value_t *nucleus, int n) { unsigned ruleno; unsigned word; @@ -175,17 +181,17 @@ finalize_closure(void) #ifdef DEBUG -void +static void print_closure(int n) { - short *isp; + Value_t *isp; printf("\n\nn = %d\n\n", n); for (isp = itemset; isp < itemsetend; isp++) printf(" %d\n", *isp); } -void +static void print_EFF(void) { int i, j; @@ -216,7 +222,7 @@ print_EFF(void) } } -void +static void print_first_derives(void) { int i; diff --git a/contrib/byacc/config.guess b/contrib/byacc/config.guess index 6ea345452..1f5c50c0d 100755 --- a/contrib/byacc/config.guess +++ b/contrib/byacc/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2013 Free Software Foundation, Inc. +# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2013-02-04' +timestamp='2014-03-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2013 Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -132,6 +132,27 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in @@ -805,7 +826,7 @@ EOF *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; - i*:MSYS*:*) + *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) @@ -853,21 +874,21 @@ EOF exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -880,59 +901,54 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build @@ -951,54 +967,63 @@ EOF #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-gnu + echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu + echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1231,19 +1256,31 @@ EOF exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) @@ -1334,154 +1371,6 @@ EOF exit ;; esac -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - cat >&2 <." version="\ GNU config.sub ($timestamp) -Copyright 1992-2013 Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -252,12 +252,12 @@ case $basic_machine in | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc \ + | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ - | c4x | clipper \ + | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ @@ -265,6 +265,7 @@ case $basic_machine in | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ @@ -295,8 +296,7 @@ case $basic_machine in | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | open8 \ - | or32 \ + | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ @@ -324,7 +324,7 @@ case $basic_machine in c6x) basic_machine=tic6x-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -366,13 +366,13 @@ case $basic_machine in | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ @@ -381,6 +381,7 @@ case $basic_machine in | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ @@ -413,6 +414,7 @@ case $basic_machine in | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ @@ -794,7 +796,7 @@ case $basic_machine in os=-mingw64 ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; mingw32ce) @@ -830,7 +832,7 @@ case $basic_machine in basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) - basic_machine=i386-pc + basic_machine=i686-pc os=-msys ;; mvs) @@ -1374,7 +1376,7 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1546,6 +1548,9 @@ case $basic_machine in c4x-* | tic4x-*) os=-coff ;; + c8051-*) + os=-elf + ;; hexagon-*) os=-elf ;; diff --git a/contrib/byacc/config_h.in b/contrib/byacc/config_h.in index afd46fd96..c7d6d9108 100644 --- a/contrib/byacc/config_h.in +++ b/contrib/byacc/config_h.in @@ -30,6 +30,12 @@ /* Define to 1 if mkstemp() is available and working. */ #undef HAVE_MKSTEMP +/* Define to 1 if vsnprintf() is available and working. */ +#undef HAVE_VSNPRINTF + +/* Define to maximum table size (default: 32500) */ +#undef MAXTABLE + /* Define to 1 if filesystem supports mixed-case filenames. */ #undef MIXEDCASE_FILENAMES @@ -48,5 +54,8 @@ /* "Define to 1 if you want to use valgrind for testing." */ #undef USE_VALGRIND +/* Define to 1 to enable backtracking extension */ +#undef YYBTYACC + /* Define to 1 if you want to perform memory-leak testing. */ #undef YY_NO_LEAKS diff --git a/contrib/byacc/configure b/contrib/byacc/configure index 24049ce22..d2b654f06 100755 --- a/contrib/byacc/configure +++ b/contrib/byacc/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.14 . +# From configure.in Revision: 1.19 . # Guess values for system-dependent variables and create Makefiles. # Generated by Autoconf 2.52.20121002. # @@ -652,6 +652,9 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-max-table-size=N set the maximum table size = N (no default) + --enable-btyacc turn on support for the btyacc backtracking + extension (default: no) --with-warnings test: turn on gcc warnings --disable-echo do not display "compiling" commands --with-dmalloc test: use Gray Watson's dmalloc library @@ -851,7 +854,7 @@ if test -z "$CONFIG_SITE"; then fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then - { echo "$as_me:854: loading site script $ac_site_file" >&5 + { echo "$as_me:857: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} cat "$ac_site_file" >&5 . "$ac_site_file" @@ -862,7 +865,7 @@ if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then - { echo "$as_me:865: loading cache $cache_file" >&5 + { echo "$as_me:868: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; @@ -870,7 +873,7 @@ echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { echo "$as_me:873: creating cache $cache_file" >&5 + { echo "$as_me:876: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -886,21 +889,21 @@ for ac_var in `(set) 2>&1 | eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) - { echo "$as_me:889: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { echo "$as_me:892: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { echo "$as_me:893: error: \`$ac_var' was not set in the previous run" >&5 + { echo "$as_me:896: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:899: error: \`$ac_var' has changed since the previous run:" >&5 + { echo "$as_me:902: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:901: former value: $ac_old_val" >&5 + { echo "$as_me:904: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:903: current value: $ac_new_val" >&5 + { echo "$as_me:906: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; @@ -919,9 +922,9 @@ echo "$as_me: current value: $ac_new_val" >&2;} fi done if $ac_cache_corrupted; then - { echo "$as_me:922: error: changes in the environment can compromise the build" >&5 + { echo "$as_me:925: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:924: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 + { { echo "$as_me:927: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi @@ -942,10 +945,10 @@ esac echo "#! $SHELL" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh -if { (echo "$as_me:945: PATH=\".;.\"; conftest.sh") >&5 +if { (echo "$as_me:948: PATH=\".;.\"; conftest.sh") >&5 (PATH=".;."; conftest.sh) 2>&5 ac_status=$? - echo "$as_me:948: \$? = $ac_status" >&5 + echo "$as_me:951: \$? = $ac_status" >&5 (exit $ac_status); }; then ac_path_separator=';' else @@ -973,7 +976,7 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:976: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 + { { echo "$as_me:979: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi @@ -983,11 +986,11 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:986: error: cannot run $ac_config_sub" >&5 + { { echo "$as_me:989: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } -echo "$as_me:990: checking build system type" >&5 +echo "$as_me:993: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -996,23 +999,23 @@ else test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && - { { echo "$as_me:999: error: cannot guess build type; you must specify one" >&5 + { { echo "$as_me:1002: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || - { { echo "$as_me:1003: error: $ac_config_sub $ac_cv_build_alias failed." >&5 + { { echo "$as_me:1006: error: $ac_config_sub $ac_cv_build_alias failed." >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;} { (exit 1); exit 1; }; } fi -echo "$as_me:1008: result: $ac_cv_build" >&5 +echo "$as_me:1011: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$as_me:1015: checking host system type" >&5 +echo "$as_me:1018: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1021,12 +1024,12 @@ else test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || - { { echo "$as_me:1024: error: $ac_config_sub $ac_cv_host_alias failed" >&5 + { { echo "$as_me:1027: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi -echo "$as_me:1029: result: $ac_cv_host" >&5 +echo "$as_me:1032: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` @@ -1034,7 +1037,7 @@ host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then - echo "$as_me:1037: checking target system type" >&5 + echo "$as_me:1040: checking target system type" >&5 echo $ECHO_N "checking target system type... $ECHO_C" >&6 if test "${ac_cv_target+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1043,12 +1046,12 @@ else test "x$ac_cv_target_alias" = "x" && ac_cv_target_alias=$ac_cv_host_alias ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || - { { echo "$as_me:1046: error: $ac_config_sub $ac_cv_target_alias failed" >&5 + { { echo "$as_me:1049: error: $ac_config_sub $ac_cv_target_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} { (exit 1); exit 1; }; } fi -echo "$as_me:1051: result: $ac_cv_target" >&5 +echo "$as_me:1054: result: $ac_cv_target" >&5 echo "${ECHO_T}$ac_cv_target" >&6 target=$ac_cv_target target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` @@ -1080,13 +1083,13 @@ else fi test -z "$system_name" && system_name="$cf_cv_system_name" -test -n "$cf_cv_system_name" && echo "$as_me:1083: result: Configuring for $cf_cv_system_name" >&5 +test -n "$cf_cv_system_name" && echo "$as_me:1086: result: Configuring for $cf_cv_system_name" >&5 echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6 if test ".$system_name" != ".$cf_cv_system_name" ; then - echo "$as_me:1087: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5 + echo "$as_me:1090: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5 echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6 - { { echo "$as_me:1089: error: \"Please remove config.cache and try again.\"" >&5 + { { echo "$as_me:1092: error: \"Please remove config.cache and try again.\"" >&5 echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;} { (exit 1); exit 1; }; } fi @@ -1113,7 +1116,7 @@ ac_main_return=return if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:1116: checking for $ac_word" >&5 +echo "$as_me:1119: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1128,7 +1131,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}gcc" -echo "$as_me:1131: found $ac_dir/$ac_word" >&5 +echo "$as_me:1134: found $ac_dir/$ac_word" >&5 break done @@ -1136,10 +1139,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1139: result: $CC" >&5 + echo "$as_me:1142: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1142: result: no" >&5 + echo "$as_me:1145: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1148,7 +1151,7 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo "$as_me:1151: checking for $ac_word" >&5 +echo "$as_me:1154: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1163,7 +1166,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="gcc" -echo "$as_me:1166: found $ac_dir/$ac_word" >&5 +echo "$as_me:1169: found $ac_dir/$ac_word" >&5 break done @@ -1171,10 +1174,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1174: result: $ac_ct_CC" >&5 + echo "$as_me:1177: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1177: result: no" >&5 + echo "$as_me:1180: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1187,7 +1190,7 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:1190: checking for $ac_word" >&5 +echo "$as_me:1193: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1202,7 +1205,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}cc" -echo "$as_me:1205: found $ac_dir/$ac_word" >&5 +echo "$as_me:1208: found $ac_dir/$ac_word" >&5 break done @@ -1210,10 +1213,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1213: result: $CC" >&5 + echo "$as_me:1216: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1216: result: no" >&5 + echo "$as_me:1219: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1222,7 +1225,7 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:1225: checking for $ac_word" >&5 +echo "$as_me:1228: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1237,7 +1240,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="cc" -echo "$as_me:1240: found $ac_dir/$ac_word" >&5 +echo "$as_me:1243: found $ac_dir/$ac_word" >&5 break done @@ -1245,10 +1248,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1248: result: $ac_ct_CC" >&5 + echo "$as_me:1251: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1251: result: no" >&5 + echo "$as_me:1254: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1261,7 +1264,7 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:1264: checking for $ac_word" >&5 +echo "$as_me:1267: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1281,7 +1284,7 @@ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then continue fi ac_cv_prog_CC="cc" -echo "$as_me:1284: found $ac_dir/$ac_word" >&5 +echo "$as_me:1287: found $ac_dir/$ac_word" >&5 break done @@ -1303,10 +1306,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1306: result: $CC" >&5 + echo "$as_me:1309: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1309: result: no" >&5 + echo "$as_me:1312: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1317,7 +1320,7 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:1320: checking for $ac_word" >&5 +echo "$as_me:1323: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1332,7 +1335,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="$ac_tool_prefix$ac_prog" -echo "$as_me:1335: found $ac_dir/$ac_word" >&5 +echo "$as_me:1338: found $ac_dir/$ac_word" >&5 break done @@ -1340,10 +1343,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1343: result: $CC" >&5 + echo "$as_me:1346: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1346: result: no" >&5 + echo "$as_me:1349: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1356,7 +1359,7 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:1359: checking for $ac_word" >&5 +echo "$as_me:1362: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1371,7 +1374,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="$ac_prog" -echo "$as_me:1374: found $ac_dir/$ac_word" >&5 +echo "$as_me:1377: found $ac_dir/$ac_word" >&5 break done @@ -1379,10 +1382,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1382: result: $ac_ct_CC" >&5 + echo "$as_me:1385: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1385: result: no" >&5 + echo "$as_me:1388: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1394,32 +1397,32 @@ fi fi -test -z "$CC" && { { echo "$as_me:1397: error: no acceptable cc found in \$PATH" >&5 +test -z "$CC" && { { echo "$as_me:1400: error: no acceptable cc found in \$PATH" >&5 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. -echo "$as_me:1402:" \ +echo "$as_me:1405:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:1405: \"$ac_compiler --version &5\"") >&5 +{ (eval echo "$as_me:1408: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? - echo "$as_me:1408: \$? = $ac_status" >&5 + echo "$as_me:1411: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:1410: \"$ac_compiler -v &5\"") >&5 +{ (eval echo "$as_me:1413: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? - echo "$as_me:1413: \$? = $ac_status" >&5 + echo "$as_me:1416: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:1415: \"$ac_compiler -V &5\"") >&5 +{ (eval echo "$as_me:1418: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? - echo "$as_me:1418: \$? = $ac_status" >&5 + echo "$as_me:1421: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF -#line 1422 "configure" +#line 1425 "configure" #include "confdefs.h" int @@ -1435,13 +1438,13 @@ ac_clean_files="$ac_clean_files a.out a.exe" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:1438: checking for C compiler default output" >&5 +echo "$as_me:1441: checking for C compiler default output" >&5 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:1441: \"$ac_link_default\"") >&5 +if { (eval echo "$as_me:1444: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? - echo "$as_me:1444: \$? = $ac_status" >&5 + echo "$as_me:1447: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last @@ -1464,34 +1467,34 @@ done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ { echo "$as_me:1467: error: C compiler cannot create executables" >&5 +{ { echo "$as_me:1470: error: C compiler cannot create executables" >&5 echo "$as_me: error: C compiler cannot create executables" >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext -echo "$as_me:1473: result: $ac_file" >&5 +echo "$as_me:1476: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:1478: checking whether the C compiler works" >&5 +echo "$as_me:1481: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (eval echo "$as_me:1484: \"$ac_try\"") >&5 + { (eval echo "$as_me:1487: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1487: \$? = $ac_status" >&5 + echo "$as_me:1490: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { echo "$as_me:1494: error: cannot run C compiled programs. + { { echo "$as_me:1497: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&2;} @@ -1499,24 +1502,24 @@ If you meant to cross compile, use \`--host'." >&2;} fi fi fi -echo "$as_me:1502: result: yes" >&5 +echo "$as_me:1505: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:1509: checking whether we are cross compiling" >&5 +echo "$as_me:1512: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:1511: result: $cross_compiling" >&5 +echo "$as_me:1514: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 -echo "$as_me:1514: checking for executable suffix" >&5 +echo "$as_me:1517: checking for executable suffix" >&5 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 -if { (eval echo "$as_me:1516: \"$ac_link\"") >&5 +if { (eval echo "$as_me:1519: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:1519: \$? = $ac_status" >&5 + echo "$as_me:1522: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will @@ -1532,25 +1535,25 @@ for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do esac done else - { { echo "$as_me:1535: error: cannot compute EXEEXT: cannot compile and link" >&5 + { { echo "$as_me:1538: error: cannot compute EXEEXT: cannot compile and link" >&5 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext -echo "$as_me:1541: result: $ac_cv_exeext" >&5 +echo "$as_me:1544: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -echo "$as_me:1547: checking for object suffix" >&5 +echo "$as_me:1550: checking for object suffix" >&5 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 1553 "configure" +#line 1556 "configure" #include "confdefs.h" int @@ -1562,10 +1565,10 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:1565: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1568: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1568: \$? = $ac_status" >&5 + echo "$as_me:1571: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in @@ -1577,24 +1580,24 @@ done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ { echo "$as_me:1580: error: cannot compute OBJEXT: cannot compile" >&5 +{ { echo "$as_me:1583: error: cannot compute OBJEXT: cannot compile" >&5 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -echo "$as_me:1587: result: $ac_cv_objext" >&5 +echo "$as_me:1590: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:1591: checking whether we are using the GNU C compiler" >&5 +echo "$as_me:1594: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 1597 "configure" +#line 1600 "configure" #include "confdefs.h" int @@ -1609,16 +1612,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1612: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1615: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1615: \$? = $ac_status" >&5 + echo "$as_me:1618: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1618: \"$ac_try\"") >&5 + { (eval echo "$as_me:1621: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1621: \$? = $ac_status" >&5 + echo "$as_me:1624: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else @@ -1630,19 +1633,19 @@ rm -f conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:1633: result: $ac_cv_c_compiler_gnu" >&5 +echo "$as_me:1636: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" -echo "$as_me:1639: checking whether $CC accepts -g" >&5 +echo "$as_me:1642: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 1645 "configure" +#line 1648 "configure" #include "confdefs.h" int @@ -1654,16 +1657,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1657: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1660: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1660: \$? = $ac_status" >&5 + echo "$as_me:1663: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1663: \"$ac_try\"") >&5 + { (eval echo "$as_me:1666: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1666: \$? = $ac_status" >&5 + echo "$as_me:1669: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else @@ -1673,7 +1676,7 @@ ac_cv_prog_cc_g=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:1676: result: $ac_cv_prog_cc_g" >&5 +echo "$as_me:1679: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -1700,16 +1703,16 @@ cat >conftest.$ac_ext <<_ACEOF #endif _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1703: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1706: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1706: \$? = $ac_status" >&5 + echo "$as_me:1709: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1709: \"$ac_try\"") >&5 + { (eval echo "$as_me:1712: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1712: \$? = $ac_status" >&5 + echo "$as_me:1715: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ ''\ @@ -1721,7 +1724,7 @@ if { (eval echo "$as_me:1703: \"$ac_compile\"") >&5 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF -#line 1724 "configure" +#line 1727 "configure" #include "confdefs.h" #include $ac_declaration @@ -1734,16 +1737,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1737: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1740: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1740: \$? = $ac_status" >&5 + echo "$as_me:1743: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1743: \"$ac_try\"") >&5 + { (eval echo "$as_me:1746: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1746: \$? = $ac_status" >&5 + echo "$as_me:1749: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -1753,7 +1756,7 @@ continue fi rm -f conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF -#line 1756 "configure" +#line 1759 "configure" #include "confdefs.h" $ac_declaration int @@ -1765,16 +1768,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1768: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1771: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1771: \$? = $ac_status" >&5 + echo "$as_me:1774: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1774: \"$ac_try\"") >&5 + { (eval echo "$as_me:1777: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1777: \$? = $ac_status" >&5 + echo "$as_me:1780: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else @@ -1804,15 +1807,15 @@ ac_main_return=return GCC_VERSION=none if test "$GCC" = yes ; then - echo "$as_me:1807: checking version of $CC" >&5 + echo "$as_me:1810: checking version of $CC" >&5 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown - echo "$as_me:1811: result: $GCC_VERSION" >&5 + echo "$as_me:1814: result: $GCC_VERSION" >&5 echo "${ECHO_T}$GCC_VERSION" >&6 fi -echo "$as_me:1815: checking for $CC option to accept ANSI C" >&5 +echo "$as_me:1818: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1820,7 +1823,7 @@ else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF -#line 1823 "configure" +#line 1826 "configure" #include "confdefs.h" #include #include @@ -1869,16 +1872,16 @@ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIO do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (eval echo "$as_me:1872: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1875: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1875: \$? = $ac_status" >&5 + echo "$as_me:1878: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1878: \"$ac_try\"") >&5 + { (eval echo "$as_me:1881: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1881: \$? = $ac_status" >&5 + echo "$as_me:1884: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break @@ -1895,10 +1898,10 @@ fi case "x$ac_cv_prog_cc_stdc" in x|xno) - echo "$as_me:1898: result: none needed" >&5 + echo "$as_me:1901: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) - echo "$as_me:1901: result: $ac_cv_prog_cc_stdc" >&5 + echo "$as_me:1904: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac @@ -1906,13 +1909,13 @@ esac # This should have been defined by AC_PROG_CC : ${CC:=cc} -echo "$as_me:1909: checking \$CC variable" >&5 +echo "$as_me:1912: checking \$CC variable" >&5 echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6 case "$CC" in #(vi *[\ \ ]-[IUD]*) - echo "$as_me:1913: result: broken" >&5 + echo "$as_me:1916: result: broken" >&5 echo "${ECHO_T}broken" >&6 - { echo "$as_me:1915: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5 + { echo "$as_me:1918: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5 echo "$as_me: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;} # humor him... cf_flags=`echo "$CC" | sed -e 's/^[^ ]*[ ]//'` @@ -1998,12 +2001,12 @@ fi ;; *) - echo "$as_me:2001: result: ok" >&5 + echo "$as_me:2004: result: ok" >&5 echo "${ECHO_T}ok" >&6 ;; esac -echo "$as_me:2006: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "$as_me:2009: checking whether ${MAKE-make} sets \${MAKE}" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then @@ -2023,11 +2026,11 @@ fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:2026: result: yes" >&5 + echo "$as_me:2029: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else - echo "$as_me:2030: result: no" >&5 + echo "$as_me:2033: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi @@ -2044,7 +2047,7 @@ fi # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:2047: checking for a BSD compatible install" >&5 +echo "$as_me:2050: checking for a BSD compatible install" >&5 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then @@ -2093,7 +2096,7 @@ fi INSTALL=$ac_install_sh fi fi -echo "$as_me:2096: result: $INSTALL" >&5 +echo "$as_me:2099: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -2104,7 +2107,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -echo "$as_me:2107: checking if filesystem supports mixed-case filenames" >&5 +echo "$as_me:2110: checking if filesystem supports mixed-case filenames" >&5 echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6 if test "${cf_cv_mixedcase+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2112,7 +2115,7 @@ else if test "$cross_compiling" = yes ; then case $target_alias in #(vi - *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi + *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*) #(vi cf_cv_mixedcase=no ;; *) @@ -2131,7 +2134,7 @@ else fi fi -echo "$as_me:2134: result: $cf_cv_mixedcase" >&5 +echo "$as_me:2137: result: $cf_cv_mixedcase" >&5 echo "${ECHO_T}$cf_cv_mixedcase" >&6 test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF @@ -2142,7 +2145,7 @@ for ac_prog in exctags ctags do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:2145: checking for $ac_word" >&5 +echo "$as_me:2148: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CTAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2157,7 +2160,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CTAGS="$ac_prog" -echo "$as_me:2160: found $ac_dir/$ac_word" >&5 +echo "$as_me:2163: found $ac_dir/$ac_word" >&5 break done @@ -2165,10 +2168,10 @@ fi fi CTAGS=$ac_cv_prog_CTAGS if test -n "$CTAGS"; then - echo "$as_me:2168: result: $CTAGS" >&5 + echo "$as_me:2171: result: $CTAGS" >&5 echo "${ECHO_T}$CTAGS" >&6 else - echo "$as_me:2171: result: no" >&5 + echo "$as_me:2174: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2179,7 +2182,7 @@ for ac_prog in exetags etags do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:2182: checking for $ac_word" >&5 +echo "$as_me:2185: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ETAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2194,7 +2197,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ETAGS="$ac_prog" -echo "$as_me:2197: found $ac_dir/$ac_word" >&5 +echo "$as_me:2200: found $ac_dir/$ac_word" >&5 break done @@ -2202,10 +2205,10 @@ fi fi ETAGS=$ac_cv_prog_ETAGS if test -n "$ETAGS"; then - echo "$as_me:2205: result: $ETAGS" >&5 + echo "$as_me:2208: result: $ETAGS" >&5 echo "${ECHO_T}$ETAGS" >&6 else - echo "$as_me:2208: result: no" >&5 + echo "$as_me:2211: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2214,7 +2217,7 @@ done # Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args. set dummy ${CTAGS:-ctags}; ac_word=$2 -echo "$as_me:2217: checking for $ac_word" >&5 +echo "$as_me:2220: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2229,7 +2232,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_MAKE_LOWER_TAGS="yes" -echo "$as_me:2232: found $ac_dir/$ac_word" >&5 +echo "$as_me:2235: found $ac_dir/$ac_word" >&5 break done @@ -2238,17 +2241,17 @@ fi fi MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS if test -n "$MAKE_LOWER_TAGS"; then - echo "$as_me:2241: result: $MAKE_LOWER_TAGS" >&5 + echo "$as_me:2244: result: $MAKE_LOWER_TAGS" >&5 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6 else - echo "$as_me:2244: result: no" >&5 + echo "$as_me:2247: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "$cf_cv_mixedcase" = yes ; then # Extract the first word of "${ETAGS:-etags}", so it can be a program name with args. set dummy ${ETAGS:-etags}; ac_word=$2 -echo "$as_me:2251: checking for $ac_word" >&5 +echo "$as_me:2254: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2263,7 +2266,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_MAKE_UPPER_TAGS="yes" -echo "$as_me:2266: found $ac_dir/$ac_word" >&5 +echo "$as_me:2269: found $ac_dir/$ac_word" >&5 break done @@ -2272,10 +2275,10 @@ fi fi MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS if test -n "$MAKE_UPPER_TAGS"; then - echo "$as_me:2275: result: $MAKE_UPPER_TAGS" >&5 + echo "$as_me:2278: result: $MAKE_UPPER_TAGS" >&5 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6 else - echo "$as_me:2278: result: no" >&5 + echo "$as_me:2281: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2295,11 +2298,52 @@ else MAKE_LOWER_TAGS="#" fi +for ac_prog in mawk gawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:2305: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_AWK="$ac_prog" +echo "$as_me:2320: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:2328: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:2331: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +test -z "$AWK" && { { echo "$as_me:2338: error: No awk program found" >&5 +echo "$as_me: error: No awk program found" >&2;} + { (exit 1); exit 1; }; } + for ac_prog in tdlint lint alint splint lclint do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:2302: checking for $ac_word" >&5 +echo "$as_me:2346: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_LINT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2314,7 +2358,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_LINT="$ac_prog" -echo "$as_me:2317: found $ac_dir/$ac_word" >&5 +echo "$as_me:2361: found $ac_dir/$ac_word" >&5 break done @@ -2322,10 +2366,10 @@ fi fi LINT=$ac_cv_prog_LINT if test -n "$LINT"; then - echo "$as_me:2325: result: $LINT" >&5 + echo "$as_me:2369: result: $LINT" >&5 echo "${ECHO_T}$LINT" >&6 else - echo "$as_me:2328: result: no" >&5 + echo "$as_me:2372: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2340,7 +2384,7 @@ case $host_os in #(vi aix[4-7]*) #(vi cf_xopen_source="-D_ALL_SOURCE" ;; -cygwin) #(vi +cygwin|msys) #(vi cf_XOPEN_SOURCE=600 ;; darwin[0-8].*) #(vi @@ -2370,14 +2414,14 @@ irix[56].*) #(vi ;; linux*|gnu*|mint*|k*bsd*-gnu) #(vi -echo "$as_me:2373: checking if we must define _GNU_SOURCE" >&5 +echo "$as_me:2417: checking if we must define _GNU_SOURCE" >&5 echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6 if test "${cf_cv_gnu_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 2380 "configure" +#line 2424 "configure" #include "confdefs.h" #include int @@ -2392,16 +2436,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2395: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2439: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2398: \$? = $ac_status" >&5 + echo "$as_me:2442: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2401: \"$ac_try\"") >&5 + { (eval echo "$as_me:2445: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2404: \$? = $ac_status" >&5 + echo "$as_me:2448: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_gnu_source=no else @@ -2410,7 +2454,7 @@ cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" cat >conftest.$ac_ext <<_ACEOF -#line 2413 "configure" +#line 2457 "configure" #include "confdefs.h" #include int @@ -2425,16 +2469,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2428: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2472: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2431: \$? = $ac_status" >&5 + echo "$as_me:2475: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2434: \"$ac_try\"") >&5 + { (eval echo "$as_me:2478: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2437: \$? = $ac_status" >&5 + echo "$as_me:2481: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_gnu_source=no else @@ -2449,7 +2493,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2452: result: $cf_cv_gnu_source" >&5 +echo "$as_me:2496: result: $cf_cv_gnu_source" >&5 echo "${ECHO_T}$cf_cv_gnu_source" >&6 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" @@ -2471,16 +2515,16 @@ cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` -echo "$as_me:2474: checking if we should define _POSIX_C_SOURCE" >&5 +echo "$as_me:2518: checking if we should define _POSIX_C_SOURCE" >&5 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6 if test "${cf_cv_posix_c_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -echo "${as_me:-configure}:2480: testing if the symbol is already defined go no further ..." 1>&5 +echo "${as_me:-configure}:2524: testing if the symbol is already defined go no further ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 2483 "configure" +#line 2527 "configure" #include "confdefs.h" #include int @@ -2495,16 +2539,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2498: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2542: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2501: \$? = $ac_status" >&5 + echo "$as_me:2545: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2504: \"$ac_try\"") >&5 + { (eval echo "$as_me:2548: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2507: \$? = $ac_status" >&5 + echo "$as_me:2551: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_posix_c_source=no else @@ -2525,7 +2569,7 @@ cf_want_posix_source=no esac if test "$cf_want_posix_source" = yes ; then cat >conftest.$ac_ext <<_ACEOF -#line 2528 "configure" +#line 2572 "configure" #include "confdefs.h" #include int @@ -2540,16 +2584,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2543: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2587: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2546: \$? = $ac_status" >&5 + echo "$as_me:2590: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2549: \"$ac_try\"") >&5 + { (eval echo "$as_me:2593: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2552: \$? = $ac_status" >&5 + echo "$as_me:2596: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -2560,15 +2604,15 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "${as_me:-configure}:2563: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 +echo "${as_me:-configure}:2607: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" -echo "${as_me:-configure}:2568: testing if the second compile does not leave our definition intact error ..." 1>&5 +echo "${as_me:-configure}:2612: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 2571 "configure" +#line 2615 "configure" #include "confdefs.h" #include int @@ -2583,16 +2627,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2586: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2630: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2589: \$? = $ac_status" >&5 + echo "$as_me:2633: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2592: \"$ac_try\"") >&5 + { (eval echo "$as_me:2636: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2595: \$? = $ac_status" >&5 + echo "$as_me:2639: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -2608,7 +2652,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2611: result: $cf_cv_posix_c_source" >&5 +echo "$as_me:2655: result: $cf_cv_posix_c_source" >&5 echo "${ECHO_T}$cf_cv_posix_c_source" >&6 if test "$cf_cv_posix_c_source" != no ; then @@ -2718,17 +2762,18 @@ sco*) #(vi ;; solaris2.*) #(vi cf_xopen_source="-D__EXTENSIONS__" + cf_cv_xopen_source=broken ;; *) -echo "$as_me:2724: checking if we should define _XOPEN_SOURCE" >&5 +echo "$as_me:2769: checking if we should define _XOPEN_SOURCE" >&5 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6 if test "${cf_cv_xopen_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 2731 "configure" +#line 2776 "configure" #include "confdefs.h" #include @@ -2747,16 +2792,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2750: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2795: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2753: \$? = $ac_status" >&5 + echo "$as_me:2798: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2756: \"$ac_try\"") >&5 + { (eval echo "$as_me:2801: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2759: \$? = $ac_status" >&5 + echo "$as_me:2804: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -2765,7 +2810,7 @@ cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >conftest.$ac_ext <<_ACEOF -#line 2768 "configure" +#line 2813 "configure" #include "confdefs.h" #include @@ -2784,16 +2829,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2787: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2832: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2790: \$? = $ac_status" >&5 + echo "$as_me:2835: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2793: \"$ac_try\"") >&5 + { (eval echo "$as_me:2838: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2796: \$? = $ac_status" >&5 + echo "$as_me:2841: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -2808,7 +2853,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2811: result: $cf_cv_xopen_source" >&5 +echo "$as_me:2856: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -2916,16 +2961,16 @@ cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` -echo "$as_me:2919: checking if we should define _POSIX_C_SOURCE" >&5 +echo "$as_me:2964: checking if we should define _POSIX_C_SOURCE" >&5 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6 if test "${cf_cv_posix_c_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -echo "${as_me:-configure}:2925: testing if the symbol is already defined go no further ..." 1>&5 +echo "${as_me:-configure}:2970: testing if the symbol is already defined go no further ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 2928 "configure" +#line 2973 "configure" #include "confdefs.h" #include int @@ -2940,16 +2985,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2943: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2988: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2946: \$? = $ac_status" >&5 + echo "$as_me:2991: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2949: \"$ac_try\"") >&5 + { (eval echo "$as_me:2994: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2952: \$? = $ac_status" >&5 + echo "$as_me:2997: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_posix_c_source=no else @@ -2970,7 +3015,7 @@ cf_want_posix_source=no esac if test "$cf_want_posix_source" = yes ; then cat >conftest.$ac_ext <<_ACEOF -#line 2973 "configure" +#line 3018 "configure" #include "confdefs.h" #include int @@ -2985,16 +3030,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2988: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3033: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2991: \$? = $ac_status" >&5 + echo "$as_me:3036: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2994: \"$ac_try\"") >&5 + { (eval echo "$as_me:3039: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2997: \$? = $ac_status" >&5 + echo "$as_me:3042: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -3005,15 +3050,15 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "${as_me:-configure}:3008: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 +echo "${as_me:-configure}:3053: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" -echo "${as_me:-configure}:3013: testing if the second compile does not leave our definition intact error ..." 1>&5 +echo "${as_me:-configure}:3058: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 3016 "configure" +#line 3061 "configure" #include "confdefs.h" #include int @@ -3028,16 +3073,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3031: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3076: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3034: \$? = $ac_status" >&5 + echo "$as_me:3079: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3037: \"$ac_try\"") >&5 + { (eval echo "$as_me:3082: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3040: \$? = $ac_status" >&5 + echo "$as_me:3085: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -3053,7 +3098,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:3056: result: $cf_cv_posix_c_source" >&5 +echo "$as_me:3101: result: $cf_cv_posix_c_source" >&5 echo "${ECHO_T}$cf_cv_posix_c_source" >&6 if test "$cf_cv_posix_c_source" != no ; then @@ -3226,10 +3271,10 @@ fi fi if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then - echo "$as_me:3229: checking if _XOPEN_SOURCE really is set" >&5 + echo "$as_me:3274: checking if _XOPEN_SOURCE really is set" >&5 echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line 3232 "configure" +#line 3277 "configure" #include "confdefs.h" #include int @@ -3244,16 +3289,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3247: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3292: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3250: \$? = $ac_status" >&5 + echo "$as_me:3295: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3253: \"$ac_try\"") >&5 + { (eval echo "$as_me:3298: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3256: \$? = $ac_status" >&5 + echo "$as_me:3301: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_XOPEN_SOURCE_set=yes else @@ -3262,12 +3307,12 @@ cat conftest.$ac_ext >&5 cf_XOPEN_SOURCE_set=no fi rm -f conftest.$ac_objext conftest.$ac_ext - echo "$as_me:3265: result: $cf_XOPEN_SOURCE_set" >&5 + echo "$as_me:3310: result: $cf_XOPEN_SOURCE_set" >&5 echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6 if test $cf_XOPEN_SOURCE_set = yes then cat >conftest.$ac_ext <<_ACEOF -#line 3270 "configure" +#line 3315 "configure" #include "confdefs.h" #include int @@ -3282,16 +3327,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3285: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3330: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3288: \$? = $ac_status" >&5 + echo "$as_me:3333: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3291: \"$ac_try\"") >&5 + { (eval echo "$as_me:3336: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3294: \$? = $ac_status" >&5 + echo "$as_me:3339: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_XOPEN_SOURCE_set_ok=yes else @@ -3302,19 +3347,19 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext if test $cf_XOPEN_SOURCE_set_ok = no then - { echo "$as_me:3305: WARNING: _XOPEN_SOURCE is lower than requested" >&5 + { echo "$as_me:3350: WARNING: _XOPEN_SOURCE is lower than requested" >&5 echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;} fi else -echo "$as_me:3310: checking if we should define _XOPEN_SOURCE" >&5 +echo "$as_me:3355: checking if we should define _XOPEN_SOURCE" >&5 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6 if test "${cf_cv_xopen_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3317 "configure" +#line 3362 "configure" #include "confdefs.h" #include @@ -3333,16 +3378,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3336: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3381: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3339: \$? = $ac_status" >&5 + echo "$as_me:3384: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3342: \"$ac_try\"") >&5 + { (eval echo "$as_me:3387: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3345: \$? = $ac_status" >&5 + echo "$as_me:3390: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -3351,7 +3396,7 @@ cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >conftest.$ac_ext <<_ACEOF -#line 3354 "configure" +#line 3399 "configure" #include "confdefs.h" #include @@ -3370,16 +3415,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3373: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3418: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3376: \$? = $ac_status" >&5 + echo "$as_me:3421: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3379: \"$ac_try\"") >&5 + { (eval echo "$as_me:3424: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3382: \$? = $ac_status" >&5 + echo "$as_me:3427: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -3394,7 +3439,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:3397: result: $cf_cv_xopen_source" >&5 +echo "$as_me:3442: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -3498,7 +3543,7 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return=return -echo "$as_me:3501: checking how to run the C preprocessor" >&5 +echo "$as_me:3546: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then @@ -3519,18 +3564,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 3522 "configure" +#line 3567 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:3527: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3572: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3533: \$? = $ac_status" >&5 + echo "$as_me:3578: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3553,17 +3598,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 3556 "configure" +#line 3601 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:3560: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3605: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3566: \$? = $ac_status" >&5 + echo "$as_me:3611: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3600,7 +3645,7 @@ fi else ac_cv_prog_CPP=$CPP fi -echo "$as_me:3603: result: $CPP" >&5 +echo "$as_me:3648: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -3610,18 +3655,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 3613 "configure" +#line 3658 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:3618: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3663: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3624: \$? = $ac_status" >&5 + echo "$as_me:3669: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3644,17 +3689,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 3647 "configure" +#line 3692 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:3651: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3696: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3657: \$? = $ac_status" >&5 + echo "$as_me:3702: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3682,7 +3727,7 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { echo "$as_me:3685: error: C preprocessor \"$CPP\" fails sanity check" >&5 + { { echo "$as_me:3730: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi @@ -3697,23 +3742,23 @@ ac_main_return=return for ac_header in fcntl.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:3700: checking for $ac_header" >&5 +echo "$as_me:3745: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3706 "configure" +#line 3751 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:3710: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3755: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3716: \$? = $ac_status" >&5 + echo "$as_me:3761: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3732,7 +3777,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:3735: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:3780: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:3790: checking for working mkstemp" >&5 echo $ECHO_N "checking for working mkstemp... $ECHO_C" >&6 if test "${cf_cv_func_mkstemp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3753,7 +3798,7 @@ if test "$cross_compiling" = yes; then cf_cv_func_mkstemp=maybe else cat >conftest.$ac_ext <<_ACEOF -#line 3756 "configure" +#line 3801 "configure" #include "confdefs.h" #include @@ -3791,15 +3836,15 @@ int main() _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:3794: \"$ac_link\"") >&5 +if { (eval echo "$as_me:3839: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:3797: \$? = $ac_status" >&5 + echo "$as_me:3842: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:3799: \"$ac_try\"") >&5 + { (eval echo "$as_me:3844: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3802: \$? = $ac_status" >&5 + echo "$as_me:3847: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_func_mkstemp=yes @@ -3814,16 +3859,16 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -echo "$as_me:3817: result: $cf_cv_func_mkstemp" >&5 +echo "$as_me:3862: result: $cf_cv_func_mkstemp" >&5 echo "${ECHO_T}$cf_cv_func_mkstemp" >&6 if test "x$cf_cv_func_mkstemp" = xmaybe ; then - echo "$as_me:3820: checking for mkstemp" >&5 + echo "$as_me:3865: checking for mkstemp" >&5 echo $ECHO_N "checking for mkstemp... $ECHO_C" >&6 if test "${ac_cv_func_mkstemp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3826 "configure" +#line 3871 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char mkstemp (); below. */ @@ -3854,16 +3899,16 @@ f = mkstemp; /* workaround for ICC 12.0.3 */ if (f == 0) return 1; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:3857: \"$ac_link\"") >&5 +if { (eval echo "$as_me:3902: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:3860: \$? = $ac_status" >&5 + echo "$as_me:3905: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:3863: \"$ac_try\"") >&5 + { (eval echo "$as_me:3908: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3866: \$? = $ac_status" >&5 + echo "$as_me:3911: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_mkstemp=yes else @@ -3873,7 +3918,7 @@ ac_cv_func_mkstemp=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:3876: result: $ac_cv_func_mkstemp" >&5 +echo "$as_me:3921: result: $ac_cv_func_mkstemp" >&5 echo "${ECHO_T}$ac_cv_func_mkstemp" >&6 fi @@ -3885,9 +3930,128 @@ EOF fi +for ac_func in vsnprintf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:3936: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 3942 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3973: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3976: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3979: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3982: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:3992: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <&5 +echo $ECHO_N "checking for maximum table size... $ECHO_C" >&6 + +# Check whether --with-max-table-size or --without-max-table-size was given. +if test "${with_max_table_size+set}" = set; then + withval="$with_max_table_size" + +fi; +if test -n "$with_max_table_size" +then + echo "$as_me:4012: result: $with_max_table_size" >&5 +echo "${ECHO_T}$with_max_table_size" >&6 + check=`expr "$with_max_table_size" + 0` + if test "x$check" != "x$with_max_table_size" + then + { { echo "$as_me:4017: error: invalid value for --with-max-table-size: $with_max_table_size" >&5 +echo "$as_me: error: invalid value for --with-max-table-size: $with_max_table_size" >&2;} + { (exit 1); exit 1; }; } + fi + +cat >>confdefs.h <&5 +echo "${ECHO_T}default" >&6 +fi + +echo "$as_me:4031: checking if backtracking extension is wanted" >&5 +echo $ECHO_N "checking if backtracking extension is wanted... $ECHO_C" >&6 + +# Check whether --enable-btyacc or --disable-btyacc was given. +if test "${enable_btyacc+set}" = set; then + enableval="$enable_btyacc" + +fi; +echo "$as_me:4039: result: $enable_btyacc" >&5 +echo "${ECHO_T}$enable_btyacc" >&6 +if test "$enable_btyacc" = "yes"; then + +cat >>confdefs.h <<\EOF +#define YYBTYACC 1 +EOF + + SKELETON=btyaccpar +else + SKELETON=yaccpar +fi + if ( test "$GCC" = yes || test "$GXX" = yes ) then -echo "$as_me:3890: checking if you want to check for gcc warnings" >&5 +echo "$as_me:4054: checking if you want to check for gcc warnings" >&5 echo $ECHO_N "checking if you want to check for gcc warnings... $ECHO_C" >&6 # Check whether --with-warnings or --without-warnings was given. @@ -3897,7 +4061,7 @@ if test "${with_warnings+set}" = set; then else cf_opt_with_warnings=no fi; -echo "$as_me:3900: result: $cf_opt_with_warnings" >&5 +echo "$as_me:4064: result: $cf_opt_with_warnings" >&5 echo "${ECHO_T}$cf_opt_with_warnings" >&6 if test "$cf_opt_with_warnings" != no ; then @@ -3919,10 +4083,10 @@ cat > conftest.i <&5 + { echo "$as_me:4086: checking for $CC __attribute__ directives..." >&5 echo "$as_me: checking for $CC __attribute__ directives..." >&6;} cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:4138: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3977: \$? = $ac_status" >&5 + echo "$as_me:4141: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:3979: result: ... $cf_attribute" >&5 + test -n "$verbose" && echo "$as_me:4143: result: ... $cf_attribute" >&5 echo "${ECHO_T}... $cf_attribute" >&6 cat conftest.h >>confdefs.h case $cf_attribute in #(vi @@ -4040,12 +4204,12 @@ INTEL_COMPILER=no if test "$GCC" = yes ; then case $host_os in linux*|gnu*) - echo "$as_me:4043: checking if this is really Intel C compiler" >&5 + echo "$as_me:4207: checking if this is really Intel C compiler" >&5 echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -no-gcc" cat >conftest.$ac_ext <<_ACEOF -#line 4048 "configure" +#line 4212 "configure" #include "confdefs.h" int @@ -4062,19 +4226,19 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4065: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4229: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4068: \$? = $ac_status" >&5 + echo "$as_me:4232: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4071: \"$ac_try\"") >&5 + { (eval echo "$as_me:4235: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4074: \$? = $ac_status" >&5 + echo "$as_me:4238: \$? = $ac_status" >&5 (exit $ac_status); }; }; then INTEL_COMPILER=yes -cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc" +cf_save_CFLAGS="$cf_save_CFLAGS -we147" else echo "$as_me: failed program was:" >&5 @@ -4082,7 +4246,7 @@ cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext CFLAGS="$cf_save_CFLAGS" - echo "$as_me:4085: result: $INTEL_COMPILER" >&5 + echo "$as_me:4249: result: $INTEL_COMPILER" >&5 echo "${ECHO_T}$INTEL_COMPILER" >&6 ;; esac @@ -4091,12 +4255,12 @@ fi CLANG_COMPILER=no if test "$GCC" = yes ; then - echo "$as_me:4094: checking if this is really Clang C compiler" >&5 + echo "$as_me:4258: checking if this is really Clang C compiler" >&5 echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Qunused-arguments" cat >conftest.$ac_ext <<_ACEOF -#line 4099 "configure" +#line 4263 "configure" #include "confdefs.h" int @@ -4113,16 +4277,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4116: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4280: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4119: \$? = $ac_status" >&5 + echo "$as_me:4283: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4122: \"$ac_try\"") >&5 + { (eval echo "$as_me:4286: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4125: \$? = $ac_status" >&5 + echo "$as_me:4289: \$? = $ac_status" >&5 (exit $ac_status); }; }; then CLANG_COMPILER=yes cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments" @@ -4133,12 +4297,12 @@ cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext CFLAGS="$cf_save_CFLAGS" - echo "$as_me:4136: result: $CLANG_COMPILER" >&5 + echo "$as_me:4300: result: $CLANG_COMPILER" >&5 echo "${ECHO_T}$CLANG_COMPILER" >&6 fi cat > conftest.$ac_ext <&5 + { echo "$as_me:4322: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS="-Wall" @@ -4171,12 +4335,12 @@ echo "$as_me: checking for $CC warning options..." >&6;} wd981 do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" - if { (eval echo "$as_me:4174: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:4338: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4177: \$? = $ac_status" >&5 + echo "$as_me:4341: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4179: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:4343: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi @@ -4185,16 +4349,20 @@ echo "${ECHO_T}... -$cf_opt" >&6 elif test "$GCC" = yes then - { echo "$as_me:4188: checking for $CC warning options..." >&5 + { echo "$as_me:4352: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS= cf_warn_CONST="" test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings" + cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs" + test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings= for cf_opt in W Wall \ Wbad-function-cast \ Wcast-align \ Wcast-qual \ + Wdeclaration-after-statement \ + Wextra \ Winline \ Wmissing-declarations \ Wmissing-prototypes \ @@ -4202,15 +4370,15 @@ echo "$as_me: checking for $CC warning options..." >&6;} Wpointer-arith \ Wshadow \ Wstrict-prototypes \ - Wundef $cf_warn_CONST Wwrite-strings + Wundef $cf_gcc_warnings $cf_warn_CONST Wwrite-strings do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" - if { (eval echo "$as_me:4208: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:4376: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4211: \$? = $ac_status" >&5 + echo "$as_me:4379: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4213: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:4381: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 case $cf_opt in #(vi Wcast-qual) #(vi @@ -4221,7 +4389,7 @@ echo "${ECHO_T}... -$cf_opt" >&6 [34].*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 -echo "${as_me:-configure}:4224: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:4392: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -4231,7 +4399,7 @@ echo "${as_me:-configure}:4224: testing feature is broken in gcc $GCC_VERSION .. [12].*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 -echo "${as_me:-configure}:4234: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:4402: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -4247,7 +4415,7 @@ rm -rf conftest* fi fi -echo "$as_me:4250: checking if you want to see long compiling messages" >&5 +echo "$as_me:4418: checking if you want to see long compiling messages" >&5 echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6 # Check whether --enable-echo or --disable-echo was given. @@ -4281,10 +4449,10 @@ else ECHO_CC='' fi; -echo "$as_me:4284: result: $enableval" >&5 +echo "$as_me:4452: result: $enableval" >&5 echo "${ECHO_T}$enableval" >&6 -echo "$as_me:4287: checking if you want to use dmalloc for testing" >&5 +echo "$as_me:4455: checking if you want to use dmalloc for testing" >&5 echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6 # Check whether --with-dmalloc or --without-dmalloc was given. @@ -4301,7 +4469,7 @@ EOF else with_dmalloc= fi; -echo "$as_me:4304: result: ${with_dmalloc:-no}" >&5 +echo "$as_me:4472: result: ${with_dmalloc:-no}" >&5 echo "${ECHO_T}${with_dmalloc:-no}" >&6 case .$with_cflags in #(vi @@ -4395,23 +4563,23 @@ fi esac if test "$with_dmalloc" = yes ; then - echo "$as_me:4398: checking for dmalloc.h" >&5 + echo "$as_me:4566: checking for dmalloc.h" >&5 echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4404 "configure" +#line 4572 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4408: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4576: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4414: \$? = $ac_status" >&5 + echo "$as_me:4582: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4430,11 +4598,11 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4433: result: $ac_cv_header_dmalloc_h" >&5 +echo "$as_me:4601: result: $ac_cv_header_dmalloc_h" >&5 echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 if test $ac_cv_header_dmalloc_h = yes; then -echo "$as_me:4437: checking for dmalloc_debug in -ldmalloc" >&5 +echo "$as_me:4605: checking for dmalloc_debug in -ldmalloc" >&5 echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6 if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4442,7 +4610,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldmalloc $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4445 "configure" +#line 4613 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4461,16 +4629,16 @@ dmalloc_debug (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4464: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4632: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4467: \$? = $ac_status" >&5 + echo "$as_me:4635: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4470: \"$ac_try\"") >&5 + { (eval echo "$as_me:4638: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4473: \$? = $ac_status" >&5 + echo "$as_me:4641: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dmalloc_dmalloc_debug=yes else @@ -4481,7 +4649,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4484: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 +echo "$as_me:4652: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6 if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then cat >>confdefs.h <&5 +echo "$as_me:4667: checking if you want to use dbmalloc for testing" >&5 echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6 # Check whether --with-dbmalloc or --without-dbmalloc was given. @@ -4513,7 +4681,7 @@ EOF else with_dbmalloc= fi; -echo "$as_me:4516: result: ${with_dbmalloc:-no}" >&5 +echo "$as_me:4684: result: ${with_dbmalloc:-no}" >&5 echo "${ECHO_T}${with_dbmalloc:-no}" >&6 case .$with_cflags in #(vi @@ -4607,23 +4775,23 @@ fi esac if test "$with_dbmalloc" = yes ; then - echo "$as_me:4610: checking for dbmalloc.h" >&5 + echo "$as_me:4778: checking for dbmalloc.h" >&5 echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dbmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4616 "configure" +#line 4784 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4620: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4788: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4626: \$? = $ac_status" >&5 + echo "$as_me:4794: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4642,11 +4810,11 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4645: result: $ac_cv_header_dbmalloc_h" >&5 +echo "$as_me:4813: result: $ac_cv_header_dbmalloc_h" >&5 echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6 if test $ac_cv_header_dbmalloc_h = yes; then -echo "$as_me:4649: checking for debug_malloc in -ldbmalloc" >&5 +echo "$as_me:4817: checking for debug_malloc in -ldbmalloc" >&5 echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6 if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4654,7 +4822,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldbmalloc $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4657 "configure" +#line 4825 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4673,16 +4841,16 @@ debug_malloc (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4676: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4844: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4679: \$? = $ac_status" >&5 + echo "$as_me:4847: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4682: \"$ac_try\"") >&5 + { (eval echo "$as_me:4850: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4685: \$? = $ac_status" >&5 + echo "$as_me:4853: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dbmalloc_debug_malloc=yes else @@ -4693,7 +4861,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4696: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5 +echo "$as_me:4864: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5 echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6 if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then cat >>confdefs.h <&5 +echo "$as_me:4879: checking if you want to use valgrind for testing" >&5 echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6 # Check whether --with-valgrind or --without-valgrind was given. @@ -4725,7 +4893,7 @@ EOF else with_valgrind= fi; -echo "$as_me:4728: result: ${with_valgrind:-no}" >&5 +echo "$as_me:4896: result: ${with_valgrind:-no}" >&5 echo "${ECHO_T}${with_valgrind:-no}" >&6 case .$with_cflags in #(vi @@ -4818,7 +4986,7 @@ fi ;; esac -echo "$as_me:4821: checking if you want to perform memory-leak testing" >&5 +echo "$as_me:4989: checking if you want to perform memory-leak testing" >&5 echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6 # Check whether --enable-leaks or --disable-leaks was given. @@ -4828,7 +4996,7 @@ if test "${enable_leaks+set}" = set; then else : ${with_no_leaks:=no} fi; -echo "$as_me:4831: result: $with_no_leaks" >&5 +echo "$as_me:4999: result: $with_no_leaks" >&5 echo "${ECHO_T}$with_no_leaks" >&6 if test "$with_no_leaks" = yes ; then @@ -4924,7 +5092,7 @@ DEFS=-DHAVE_CONFIG_H : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:4927: creating $CONFIG_STATUS" >&5 +{ echo "$as_me:5095: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL @@ -5097,7 +5265,7 @@ cat >>$CONFIG_STATUS <<\EOF echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header - { { echo "$as_me:5100: error: ambiguous option: $1 + { { echo "$as_me:5268: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} @@ -5116,7 +5284,7 @@ Try \`$0 --help' for more information." >&2;} ac_need_defaults=false;; # This is an error. - -*) { { echo "$as_me:5119: error: unrecognized option: $1 + -*) { { echo "$as_me:5287: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} @@ -5153,7 +5321,7 @@ do # Handling of arguments. "makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config_h.in" ;; - *) { { echo "$as_me:5156: error: invalid argument: $ac_config_target" >&5 + *) { { echo "$as_me:5324: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac @@ -5263,9 +5431,11 @@ s,@CTAGS@,$CTAGS,;t t s,@ETAGS@,$ETAGS,;t t s,@MAKE_LOWER_TAGS@,$MAKE_LOWER_TAGS,;t t s,@MAKE_UPPER_TAGS@,$MAKE_UPPER_TAGS,;t t +s,@AWK@,$AWK,;t t s,@LINT@,$LINT,;t t s,@LINT_OPTS@,$LINT_OPTS,;t t s,@CPP@,$CPP,;t t +s,@SKELETON@,$SKELETON,;t t s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t s,@ECHO_LT@,$ECHO_LT,;t t s,@ECHO_LD@,$ECHO_LD,;t t @@ -5386,7 +5556,7 @@ done; } esac if test x"$ac_file" != x-; then - { echo "$as_me:5389: creating $ac_file" >&5 + { echo "$as_me:5559: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi @@ -5404,7 +5574,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:5407: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:5577: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -5417,7 +5587,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:5420: error: cannot find input file: $f" >&5 + { { echo "$as_me:5590: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -5433,7 +5603,7 @@ cat >>$CONFIG_STATUS <<\EOF if test -n "$ac_seen"; then ac_used=`grep '@datarootdir@' $ac_item` if test -z "$ac_used"; then - { echo "$as_me:5436: WARNING: datarootdir was used implicitly but not set: + { echo "$as_me:5606: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&2;} @@ -5442,7 +5612,7 @@ $ac_seen" >&2;} fi ac_seen=`grep '${datarootdir}' $ac_item` if test -n "$ac_seen"; then - { echo "$as_me:5445: WARNING: datarootdir was used explicitly but not set: + { echo "$as_me:5615: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&2;} @@ -5479,7 +5649,7 @@ s,@INSTALL@,$ac_INSTALL,;t t ac_init=`egrep '[ ]*'$ac_name'[ ]*=' $ac_file` if test -z "$ac_init"; then ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'` - { echo "$as_me:5482: WARNING: Variable $ac_name is used but was not set: + { echo "$as_me:5652: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&5 echo "$as_me: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&2;} @@ -5490,7 +5660,7 @@ $ac_seen" >&2;} egrep -n '@[A-Z_][A-Z_0-9]+@' $ac_file >>$tmp/out if test -s $tmp/out; then ac_seen=`sed -e 's,^,'$ac_file':,' < $tmp/out` - { echo "$as_me:5493: WARNING: Some variables may not be substituted: + { echo "$as_me:5663: WARNING: Some variables may not be substituted: $ac_seen" >&5 echo "$as_me: WARNING: Some variables may not be substituted: $ac_seen" >&2;} @@ -5539,7 +5709,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue * ) ac_file_in=$ac_file.in ;; esac - test x"$ac_file" != x- && { echo "$as_me:5542: creating $ac_file" >&5 + test x"$ac_file" != x- && { echo "$as_me:5712: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the @@ -5550,7 +5720,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:5553: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:5723: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -5563,7 +5733,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:5566: error: cannot find input file: $f" >&5 + { { echo "$as_me:5736: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -5681,7 +5851,7 @@ cat >>$CONFIG_STATUS <<\EOF rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:5684: $ac_file is unchanged" >&5 + { echo "$as_me:5854: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ @@ -5748,3 +5918,51 @@ if test "$no_create" != yes; then $ac_cs_success || { (exit 1); exit 1; } fi +test -z "$cf_make_docs" && cf_make_docs=0 + +cf_output=makefile +test -f "$cf_output" || cf_output=Makefile + +if test "$cf_make_docs" = 0 +then +cat >>$cf_output <<"CF_EOF" +################################################################################ +.SUFFIXES : .html .1 .man .ps .pdf .txt + +.1.html : + GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.1 | groff -P -o0 -Iyacc,1_ -Thtml -man" >$@ + +.1.ps : + $(SHELL) -c "tbl $*.1 | groff -man" >$@ + +.1.txt : + GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.1 | nroff -Tascii -man | col -bx" >$@ + +.ps.pdf : + ps2pdf $*.ps + +CF_EOF + cf_make_docs=1 +fi + +for cf_name in yacc +do +cat >>$cf_output < #endif +#include #include #include #include @@ -30,14 +31,14 @@ #define VERSION VSTRING(YYMAJOR, YYMINOR) -/* machine-dependent definitions */ -/* the following definitions are for the Tahoe */ -/* they might have to be changed for other machines */ +/* machine-dependent definitions: */ /* MAXCHAR is the largest unsigned character value */ -/* MAXSHORT is the largest value of a C short */ -/* MINSHORT is the most negative value of a C short */ /* MAXTABLE is the maximum table size */ +/* YYINT is the smallest C integer type that can be */ +/* used to address a table of size MAXTABLE */ +/* MAXYYINT is the largest value of a YYINT */ +/* MINYYINT is the most negative value of a YYINT */ /* BITS_PER_WORD is the number of bits in a C unsigned */ /* WORDSIZE computes the number of words needed to */ /* store n bits */ @@ -45,14 +46,26 @@ /* from r (0-indexed) */ /* SETBIT sets the n-th bit starting from r */ -#define MAXCHAR 255 -#define MAXSHORT 32767 -#define MINSHORT -32768 +#define MAXCHAR UCHAR_MAX +#ifndef MAXTABLE #define MAXTABLE 32500 -#define BITS_PER_WORD 32 -#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) -#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31))&1) -#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31))) +#endif +#if MAXTABLE <= SHRT_MAX +#define YYINT short +#define MAXYYINT SHRT_MAX +#define MINYYINT SHRT_MIN +#elif MAXTABLE <= INT_MAX +#define YYINT int +#define MAXYYINT INT_MAX +#define MINYYINT INT_MIN +#else +#error "MAXTABLE is too large for this machine architecture!" +#endif + +#define BITS_PER_WORD ((int) sizeof (unsigned) * CHAR_BIT) +#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) +#define BIT(r, n) ((((r)[(n)/BITS_PER_WORD])>>((n)&(BITS_PER_WORD-1)))&1) +#define SETBIT(r, n) ((r)[(n)/BITS_PER_WORD]|=((unsigned)1<<((n)&(BITS_PER_WORD-1)))) /* character names */ @@ -104,12 +117,20 @@ #define PARSE_PARAM 13 #define LEX_PARAM 14 #define POSIX_YACC 15 +#define TOKEN_TABLE 16 + +#if defined(YYBTYACC) +#define LOCATIONS 17 +#define DESTRUCTOR 18 +#endif /* symbol classes */ #define UNKNOWN 0 #define TERM 1 #define NONTERM 2 +#define ACTION 3 +#define ARGUMENT 4 /* the undefined value */ @@ -149,10 +170,20 @@ /* messages */ #define PLURAL(n) ((n) > 1 ? "s" : "") +/* + * Features which depend indirectly on the btyacc configuration, but are not + * essential. + */ +#if defined(YYBTYACC) +#define USE_HEADER_GUARDS 1 +#else +#define USE_HEADER_GUARDS 0 +#endif + typedef char Assoc_t; typedef char Class_t; -typedef short Index_t; -typedef short Value_t; +typedef YYINT Index_t; +typedef YYINT Value_t; /* the structure of a symbol table entry */ @@ -163,6 +194,12 @@ struct bucket struct bucket *next; char *name; char *tag; +#if defined(YYBTYACC) + char **argnames; + char **argtags; + int args; + char *destructor; +#endif Value_t value; Index_t index; Value_t prec; @@ -248,6 +285,12 @@ extern int lineno; extern int outline; extern int exit_code; extern int pure_parser; +extern int token_table; +#if defined(YYBTYACC) +extern int locations; +extern int backtrack; +extern int destructor; +#endif extern const char *const banner[]; extern const char *const xdecls[]; @@ -259,9 +302,7 @@ extern const char *const hdr_vars[]; extern const char *const body_1[]; extern const char *const body_vars[]; extern const char *const body_2[]; -extern const char *const body_3[]; extern const char *const trailer[]; -extern const char *const trailer_2[]; extern char *code_file_name; extern char *input_file_name; @@ -279,11 +320,11 @@ extern FILE *union_file; extern FILE *verbose_file; extern FILE *graph_file; -extern int nitems; -extern int nrules; -extern int nsyms; -extern int ntokens; -extern int nvars; +extern Value_t nitems; +extern Value_t nrules; +extern Value_t nsyms; +extern Value_t ntokens; +extern Value_t nvars; extern int ntags; extern char unionized; @@ -296,6 +337,12 @@ extern Value_t *symbol_value; extern Value_t *symbol_prec; extern char *symbol_assoc; +#if defined(YYBTYACC) +extern Value_t *symbol_pval; +extern char **symbol_destructor; +extern char **symbol_type_tag; +#endif + extern Value_t *ritem; extern Value_t *rlhs; extern Value_t *rrhs; @@ -344,9 +391,6 @@ extern param *parse_param; /* global functions */ -extern bucket *lookup(const char *); -extern bucket *make_bucket(const char *); - #ifndef GCC_NORETURN #if defined(__dead2) #define GCC_NORETURN __dead2 @@ -365,13 +409,23 @@ extern bucket *make_bucket(const char *); #endif #endif +#ifndef GCC_PRINTFLIKE +#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#endif + /* closure.c */ extern void closure(Value_t * nucleus, int n); extern void finalize_closure(void); extern void set_first_derives(void); /* error.c */ +extern void arg_number_disagree_warning(int a_lineno, char *a_name); +extern void arg_type_disagree_warning(int a_lineno, int i, char *a_name); +extern void at_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; +extern void at_warning(int a_lineno, int i); +extern void bad_formals(void) GCC_NORETURN; extern void default_action_warning(void); +extern void destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr); extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void dollar_warning(int a_lineno, int i); extern void fatal(const char *msg) GCC_NORETURN; @@ -387,6 +441,7 @@ extern void reprec_warning(char *s); extern void restarted_warning(void); extern void retyped_warning(char *s); extern void revalued_warning(char *s); +extern void start_requires_args(char *a_name); extern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN; extern void terminal_lhs(int s_lineno) GCC_NORETURN; extern void terminal_start(char *s) GCC_NORETURN; @@ -394,24 +449,25 @@ extern void tokenized_start(char *s) GCC_NORETURN; extern void undefined_goal(char *s) GCC_NORETURN; extern void undefined_symbol_warning(char *s); extern void unexpected_EOF(void) GCC_NORETURN; +extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char *d_line, const char *d_cptr); extern void unknown_rhs(int i) GCC_NORETURN; +extern void unsupported_flag_warning(const char *flag, const char *details); extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr) GCC_NORETURN; extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr) GCC_NORETURN; extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN; extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr) GCC_NORETURN; +extern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name); extern void untyped_lhs(void) GCC_NORETURN; extern void untyped_rhs(int i, char *s) GCC_NORETURN; extern void used_reserved(char *s) GCC_NORETURN; +extern void unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; +extern void wrong_number_args_warning(const char *which, const char *a_name); +extern void wrong_type_for_arg_warning(int i, char *a_name); /* graph.c */ extern void graph(void); -/* lalr.c */ -extern void create_symbol_table(void); -extern void free_symbol_table(void); -extern void free_symbols(void); - /* lalr.c */ extern void lalr(void); @@ -430,25 +486,59 @@ extern void done(int k) GCC_NORETURN; extern void free_parser(void); extern void make_parser(void); +/* mstring.c */ +struct mstring +{ + char *base, *ptr, *end; +}; + +extern void msprintf(struct mstring *, const char *, ...) GCC_PRINTFLIKE(2,3); +extern int mputchar(struct mstring *, int); +extern struct mstring *msnew(void); +extern char *msdone(struct mstring *); +extern int strnscmp(const char *, const char *); +extern unsigned int strnshash(const char *); + +#define mputc(m, ch) (((m)->ptr == (m)->end) \ + ? mputchar(m,ch) \ + : (*(m)->ptr++ = (char) (ch))) + /* output.c */ extern void output(void); /* reader.c */ extern void reader(void); -/* skeleton.c */ +/* skeleton.c (generated by skel2c) */ extern void write_section(FILE * fp, const char *const section[]); +/* symtab.c */ +extern bucket *make_bucket(const char *); +extern bucket *lookup(const char *); +extern void create_symbol_table(void); +extern void free_symbol_table(void); +extern void free_symbols(void); + /* verbose.c */ extern void verbose(void); /* warshall.c */ extern void reflexive_transitive_closure(unsigned *R, int n); +#ifdef DEBUG + /* closure.c */ +extern void print_closure(int n); +extern void print_EFF(void); +extern void print_first_derives(void); + /* lr0.c */ +extern void print_derives(void); +#endif + #ifdef NO_LEAKS extern void lr0_leaks(void); extern void lalr_leaks(void); extern void mkpar_leaks(void); extern void output_leaks(void); +extern void mstring_leaks(void); extern void reader_leaks(void); #endif diff --git a/contrib/byacc/descrip.mms b/contrib/byacc/descrip.mms index 0dcb70fbb..007468b07 100644 --- a/contrib/byacc/descrip.mms +++ b/contrib/byacc/descrip.mms @@ -12,7 +12,7 @@ OBJS = closure.obj, \ mkpar.obj, \ output.obj, \ reader.obj, \ - skeleton.obj, \ + yaccpar.obj, \ symtab.obj, \ verbose.obj, \ warshall.obj diff --git a/contrib/byacc/error.c b/contrib/byacc/error.c index 3bab31b8a..a042aec71 100644 --- a/contrib/byacc/error.c +++ b/contrib/byacc/error.c @@ -1,4 +1,4 @@ -/* $Id: error.c,v 1.9 2011/09/05 23:27:43 tom Exp $ */ +/* $Id: error.c,v 1.11 2014/04/07 22:22:49 tom Exp $ */ /* routines for printing error messages */ @@ -42,9 +42,9 @@ unexpected_EOF(void) } static void -print_pos(char *st_line, char *st_cptr) +print_pos(const char *st_line, const char *st_cptr) { - char *s; + const char *s; if (st_line == 0) return; @@ -286,3 +286,117 @@ undefined_symbol_warning(char *s) { fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s); } + +#if ! defined(YYBTYACC) +void +unsupported_flag_warning(const char *flag, const char *details) +{ + fprintf(stderr, "%s: w - %s flag unsupported, %s\n", + myname, flag, details); +} +#endif + +#if defined(YYBTYACC) +void +at_warning(int a_lineno, int i) +{ + fprintf(stderr, "%s: w - line %d of \"%s\", @%d references beyond the \ +end of the current rule\n", myname, a_lineno, input_file_name, i); +} + +void +at_error(int a_lineno, char *a_line, char *a_cptr) +{ + fprintf(stderr, + "%s: e - line %d of \"%s\", illegal @$ or @N reference\n", + myname, a_lineno, input_file_name); + print_pos(a_line, a_cptr); + done(1); +} + +void +unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) +{ + fprintf(stderr, + "%s: e - line %d of \"%s\", unterminated argument list\n", + myname, a_lineno, input_file_name); + print_pos(a_line, a_cptr); + done(1); +} + +void +arg_number_disagree_warning(int a_lineno, char *a_name) +{ + fprintf(stderr, "%s: w - line %d of \"%s\", number of arguments of %s " + "doesn't agree with previous declaration\n", + myname, a_lineno, input_file_name, a_name); +} + +void +bad_formals(void) +{ + fprintf(stderr, "%s: e - line %d of \"%s\", bad formal argument list\n", + myname, lineno, input_file_name); + print_pos(line, cptr); + done(1); +} + +void +arg_type_disagree_warning(int a_lineno, int i, char *a_name) +{ + fprintf(stderr, "%s: w - line %d of \"%s\", type of argument %d " + "to %s doesn't agree with previous declaration\n", + myname, a_lineno, input_file_name, i, a_name); +} + +void +unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char + *d_line, const char *d_cptr) +{ + fprintf(stderr, "%s: w - line %d of \"%s\", unknown argument %s%s\n", + myname, d_lineno, input_file_name, dlr_opt, d_arg); + print_pos(d_line, d_cptr); +} + +void +untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name) +{ + fprintf(stderr, "%s: w - line %d of \"%s\", untyped argument %s%s\n", + myname, a_lineno, input_file_name, dlr_opt, a_name); +} + +void +wrong_number_args_warning(const char *which, const char *a_name) +{ + fprintf(stderr, + "%s: w - line %d of \"%s\", wrong number of %sarguments for %s\n", + myname, lineno, input_file_name, which, a_name); + print_pos(line, cptr); +} + +void +wrong_type_for_arg_warning(int i, char *a_name) +{ + fprintf(stderr, + "%s: w - line %d of \"%s\", wrong type for default argument %d to %s\n", + myname, lineno, input_file_name, i, a_name); + print_pos(line, cptr); +} + +void +start_requires_args(char *a_name) +{ + fprintf(stderr, + "%s: w - line %d of \"%s\", start symbol %s requires arguments\n", + myname, 0, input_file_name, a_name); + +} + +void +destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr) +{ + fprintf(stderr, "%s: w - line %d of \"%s\", destructor redeclared\n", + myname, a_lineno, input_file_name); + print_pos(a_line, a_cptr); +} +#endif diff --git a/contrib/byacc/graph.c b/contrib/byacc/graph.c index 2e312314d..6070fa2be 100644 --- a/contrib/byacc/graph.c +++ b/contrib/byacc/graph.c @@ -1,4 +1,4 @@ -/* $Id: graph.c,v 1.7 2009/10/27 09:25:20 tom Exp $ */ +/* $Id: graph.c,v 1.8 2014/02/19 00:46:57 Tom.Shields Exp $ */ #include "defs.h" @@ -51,10 +51,10 @@ graph(void) static void graph_state(int stateno) { - short *isp; + Value_t *isp; int rule; - short *sp; - short *sp1; + Value_t *sp; + Value_t *sp1; larno = (unsigned)lookaheads[stateno]; fprintf(graph_file, "\n\tq%d [label=\"%d:\\l", stateno, stateno); diff --git a/contrib/byacc/lalr.c b/contrib/byacc/lalr.c index eb5e309b0..f2ae5b469 100644 --- a/contrib/byacc/lalr.c +++ b/contrib/byacc/lalr.c @@ -1,4 +1,4 @@ -/* $Id: lalr.c,v 1.9 2009/10/27 09:49:27 tom Exp $ */ +/* $Id: lalr.c,v 1.10 2014/02/19 00:35:17 Tom.Shields Exp $ */ #include "defs.h" @@ -196,7 +196,7 @@ set_goto_map(void) if (ISTOKEN(symbol)) break; - if (ngotos == MAXSHORT) + if (ngotos == MAXYYINT) fatal("too many gotos"); ngotos++; diff --git a/contrib/byacc/lr0.c b/contrib/byacc/lr0.c index 641f9f800..162d1067d 100644 --- a/contrib/byacc/lr0.c +++ b/contrib/byacc/lr0.c @@ -1,4 +1,4 @@ -/* $Id: lr0.c,v 1.13 2012/05/26 00:40:47 tom Exp $ */ +/* $Id: lr0.c,v 1.16 2014/04/07 21:53:50 tom Exp $ */ #include "defs.h" @@ -28,7 +28,7 @@ static shifts *last_shift; static reductions *last_reduction; static int nshifts; -static short *shift_symbol; +static Value_t *shift_symbol; static Value_t *redset; static Value_t *shiftset; @@ -40,16 +40,16 @@ static Value_t *kernel_items; static void allocate_itemsets(void) { - short *itemp; - short *item_end; + Value_t *itemp; + Value_t *item_end; int symbol; int i; int count; int max; - short *symbol_count; + Value_t *symbol_count; count = 0; - symbol_count = NEW2(nsyms, short); + symbol_count = NEW2(nsyms, Value_t); item_end = ritem + nitems; for (itemp = ritem; itemp < item_end; itemp++) @@ -62,8 +62,8 @@ allocate_itemsets(void) } } - kernel_base = NEW2(nsyms, short *); - kernel_items = NEW2(count, short); + kernel_base = NEW2(nsyms, Value_t *); + kernel_items = NEW2(count, Value_t); count = 0; max = 0; @@ -76,15 +76,15 @@ allocate_itemsets(void) } shift_symbol = symbol_count; - kernel_end = NEW2(nsyms, short *); + kernel_end = NEW2(nsyms, Value_t *); } static void allocate_storage(void) { allocate_itemsets(); - shiftset = NEW2(nsyms, short); - redset = NEW2(nrules + 1, short); + shiftset = NEW2(nsyms, Value_t); + redset = NEW2(nrules + 1, Value_t); state_set = NEW2(nitems, core *); } @@ -133,7 +133,7 @@ static void generate_states(void) { allocate_storage(); - itemset = NEW2(nitems, short); + itemset = NEW2(nitems, Value_t); ruleset = NEW2(WORDSIZE(nrules), unsigned); set_first_derives(); initialize_states(); @@ -158,9 +158,9 @@ static Value_t get_state(int symbol) { int key; - short *isp1; - short *isp2; - short *iend; + Value_t *isp1; + Value_t *isp2; + Value_t *iend; core *sp; int found; int n; @@ -220,14 +220,14 @@ static void initialize_states(void) { unsigned i; - short *start_derives; + Value_t *start_derives; core *p; start_derives = derives[start_symbol]; for (i = 0; start_derives[i] >= 0; ++i) continue; - p = (core *)MALLOC(sizeof(core) + i * sizeof(short)); + p = (core *)MALLOC(sizeof(core) + i * sizeof(Value_t)); NO_SPACE(p); p->next = 0; @@ -248,8 +248,8 @@ new_itemsets(void) { Value_t i; int shiftcount; - short *isp; - short *ksp; + Value_t *isp; + Value_t *ksp; Value_t symbol; for (i = 0; i < nsyms; i++) @@ -283,22 +283,22 @@ new_state(int symbol) { unsigned n; core *p; - short *isp1; - short *isp2; - short *iend; + Value_t *isp1; + Value_t *isp2; + Value_t *iend; #ifdef TRACE fprintf(stderr, "Entering new_state(%d)\n", symbol); #endif - if (nstates >= MAXSHORT) + if (nstates >= MAXYYINT) fatal("too many states"); isp1 = kernel_base[symbol]; iend = kernel_end[symbol]; n = (unsigned)(iend - isp1); - p = (core *)allocate((sizeof(core) + (n - 1) * sizeof(short))); + p = (core *)allocate((sizeof(core) + (n - 1) * sizeof(Value_t))); p->accessing_symbol = (Value_t) symbol; p->number = (Value_t) nstates; p->nitems = (Value_t) n; @@ -316,7 +316,7 @@ new_state(int symbol) } /* show_cores is used for debugging */ - +#ifdef DEBUG void show_cores(void) { @@ -393,17 +393,18 @@ show_shifts(void) printf("\t%d\n", p->shift[i]); } } +#endif static void save_shifts(void) { shifts *p; - short *sp1; - short *sp2; - short *send; + Value_t *sp1; + Value_t *sp2; + Value_t *send; p = (shifts *)allocate((sizeof(shifts) + - (unsigned)(nshifts - 1) * sizeof(short))); + (unsigned)(nshifts - 1) * sizeof(Value_t))); p->number = this_state->number; p->nshifts = (Value_t) nshifts; @@ -430,13 +431,13 @@ save_shifts(void) static void save_reductions(void) { - short *isp; - short *rp1; - short *rp2; + Value_t *isp; + Value_t *rp1; + Value_t *rp2; int item; Value_t count; reductions *p; - short *rend; + Value_t *rend; count = 0; for (isp = itemset; isp < itemsetend; isp++) @@ -452,7 +453,7 @@ save_reductions(void) { p = (reductions *)allocate((sizeof(reductions) + (unsigned)(count - 1) * - sizeof(short))); + sizeof(Value_t))); p->number = this_state->number; p->nreds = count; @@ -482,10 +483,10 @@ set_derives(void) { Value_t i, k; int lhs; - short *rules; + Value_t *rules; - derives = NEW2(nsyms, short *); - rules = NEW2(nvars + nrules, short); + derives = NEW2(nsyms, Value_t *); + rules = NEW2(nvars + nrules, Value_t); k = 0; for (lhs = start_symbol; lhs < nsyms; lhs++) @@ -513,7 +514,7 @@ void print_derives(void) { int i; - short *sp; + Value_t *sp; printf("\nDERIVES\n\n"); @@ -592,8 +593,11 @@ lr0(void) void lr0_leaks(void) { - DO_FREE(derives[start_symbol]); - DO_FREE(derives); + if (derives) + { + DO_FREE(derives[start_symbol]); + DO_FREE(derives); + } DO_FREE(nullable); } #endif diff --git a/contrib/byacc/main.c b/contrib/byacc/main.c index 816e1547f..324c834cb 100644 --- a/contrib/byacc/main.c +++ b/contrib/byacc/main.c @@ -1,7 +1,11 @@ -/* $Id: main.c,v 1.40 2012/09/29 13:11:00 Adrian.Bunk Exp $ */ +/* $Id: main.c,v 1.50 2014/04/22 23:34:47 tom Exp $ */ #include +#ifndef _WIN32 #include /* for _exit() */ +#else +#include /* for _exit() */ +#endif #include "defs.h" @@ -73,20 +77,30 @@ FILE *union_file; /* a temp file, used to save the union */ FILE *verbose_file; /* y.output */ FILE *graph_file; /* y.dot */ -int nitems; -int nrules; -int nsyms; -int ntokens; -int nvars; +Value_t nitems; +Value_t nrules; +Value_t nsyms; +Value_t ntokens; +Value_t nvars; Value_t start_symbol; char **symbol_name; char **symbol_pname; Value_t *symbol_value; -short *symbol_prec; +Value_t *symbol_prec; char *symbol_assoc; int pure_parser; +int token_table; + +#if defined(YYBTYACC) +Value_t *symbol_pval; +char **symbol_destructor; +char **symbol_type_tag; +int locations = 0; /* default to no position processing */ +int backtrack = 0; /* default is no backtracking */ +#endif + int exit_code; Value_t *ritem; @@ -115,6 +129,10 @@ done(int k) { DO_CLOSE(input_file); DO_CLOSE(output_file); + if (iflag) + DO_CLOSE(externs_file); + if (rflag) + DO_CLOSE(code_file); DO_CLOSE(action_file); DO_CLOSE(defines_file); @@ -148,13 +166,11 @@ done(int k) lr0_leaks(); lalr_leaks(); mkpar_leaks(); + mstring_leaks(); output_leaks(); reader_leaks(); #endif - if (rflag) - DO_CLOSE(code_file); - exit(k); } @@ -190,11 +206,14 @@ usage(void) "" ,"Options:" ," -b file_prefix set filename prefix (default \"y.\")" - ," -d write definitions (y.tab.h)" + ," -B create a backtracking parser" + ," -d write definitions (" DEFINES_SUFFIX ")" + ," -D enable value stack memory reclamation" ," -i write interface (y.tab.i)" ," -g write a graphical description" ," -l suppress #line directives" - ," -o output_file (default \"y.tab.c\")" + ," -L enable position processing, e.g., \"%locations\"" + ," -o output_file (default \"" OUTPUT_SUFFIX "\")" ," -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)" @@ -218,6 +237,14 @@ setflag(int ch) { switch (ch) { + case 'B': +#if defined(YYBTYACC) + backtrack = 1; +#else + unsupported_flag_warning("-B", "reconfigure with --enable-btyacc"); +#endif + break; + case 'd': dflag = 1; break; @@ -234,6 +261,14 @@ setflag(int ch) lflag = 1; break; + case 'L': +#if defined(YYBTYACC) + locations = 1; +#else + unsupported_flag_warning("-B", "reconfigure with --enable-btyacc"); +#endif + break; + case 'P': pure_parser = 1; break; @@ -363,10 +398,18 @@ allocate(size_t n) } #define CREATE_FILE_NAME(dest, suffix) \ - dest = TMALLOC(char, len + strlen(suffix) + 1); \ - NO_SPACE(dest); \ - strcpy(dest, file_prefix); \ - strcpy(dest + len, suffix) + dest = alloc_file_name(len, suffix) + +static char * +alloc_file_name(size_t len, const char *suffix) +{ + char *result = TMALLOC(char, len + strlen(suffix) + 1); + if (result == 0) + no_space(); + strcpy(result, file_prefix); + strcpy(result + len, suffix); + return result; +} static void create_file_names(void) @@ -383,7 +426,7 @@ create_file_names(void) /* compute the file_prefix from the user provided output_file_name */ if (output_file_name != 0) { - if (!(prefix = strstr(output_file_name, ".tab.c")) + if (!(prefix = strstr(output_file_name, OUTPUT_SUFFIX)) && (prefix = strstr(output_file_name, ".c"))) { defines_suffix = ".h"; diff --git a/contrib/byacc/makefile.in b/contrib/byacc/makefile.in index d3d9655b1..1701862fe 100644 --- a/contrib/byacc/makefile.in +++ b/contrib/byacc/makefile.in @@ -1,4 +1,4 @@ -# $Id: makefile.in,v 1.18 2012/09/29 13:10:15 Adrian.Bunk Exp $ +# $Id: makefile.in,v 1.23 2014/04/09 12:15:52 tom Exp $ # # UNIX template-makefile for Berkeley Yacc @@ -24,9 +24,11 @@ CFLAGS = @CFLAGS@ $(CPPFLAGS) $(EXTRA_CFLAGS) LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ +AWK = @AWK@ CTAGS = @CTAGS@ ETAGS = @ETAGS@ LINT = @LINT@ +LINTFLAGS = @LINT_OPTS@ prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -38,6 +40,7 @@ manext = 1 testdir = $(srcdir)/test +SKELETON = @SKELETON@ x = @EXEEXT@ o = .@OBJEXT@ @@ -57,9 +60,10 @@ C_FILES = \ lr0.c \ main.c \ mkpar.c \ + mstring.c \ output.c \ reader.c \ - skeleton.c \ + $(SKELETON).c \ symtab.c \ verbose.c \ warshall.c @@ -72,13 +76,18 @@ OBJS = \ lr0$o \ main$o \ mkpar$o \ + mstring$o \ output$o \ reader$o \ - skeleton$o \ + $(SKELETON)$o \ symtab$o \ verbose$o \ warshall$o +YACCPAR = \ + btyaccpar.c \ + yaccpar.c + TRANSFORM_BIN = sed 's/$x$$//' |sed '$(transform)'|sed 's/$$/$x/' TRANSFORM_MAN = sed 's/$(manext)$$//'|sed '$(transform)'|sed 's/$$/$(manext)/' @@ -100,7 +109,7 @@ uninstall: - rm -f $(mandir)/$(actual_man) ################################################################################ -.SUFFIXES : $o .i .html .$(manext) .cat .ps .pdf .txt +.SUFFIXES : .c $o .i .skel .c$o: @RULE_CC@ @@ -110,20 +119,8 @@ uninstall: @RULE_CC@ @ECHO_CC@$(CPP) -C $(CPPFLAGS) $*.c >$@ -.$(manext).cat : - - nroff -man $(srcdir)/$(THIS).$(manext) >$@ - -.$(manext).html : - GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | groff -Thtml -man" >$@ - -.$(manext).ps : - $(SHELL) -c "tbl $*.$(manext) | groff -man" >$@ - -.$(manext).txt : - GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | nroff -Tascii -man | col -bx" >$@ - -.ps.pdf : - ps2pdf $*.ps +.skel.c : + $(AWK) -f $(srcdir)/skel2c $*.skel > $@ ################################################################################ @@ -133,26 +130,21 @@ $(THIS)$x : $(OBJS) mostlyclean : - rm -f core .nfs* *$o *.bak *.BAK *.out -clean : mostlyclean +clean :: mostlyclean - rm -f $(THIS)$x -distclean : clean +distclean :: clean - rm -f config.log config.cache config.status config.h makefile - - rm -f *.html *.cat *.pdf *.ps *.txt - - cd test && rm -f test-* + - rm -f $(testdir)/yacc/test-* $(testdir)/btyacc/test-* -realclean: distclean +realclean :: distclean - rm -f tags TAGS -################################################################################ -docs :: $(THIS).html \ - $(THIS).pdf \ - $(THIS).ps \ - $(THIS).txt -$(THIS).html : $(THIS).$(manext) -$(THIS).pdf : $(THIS).ps -$(THIS).ps : $(THIS).$(manext) -$(THIS).txt : $(THIS).$(manext) +sources : $(YACCPAR) + +maintainer-clean :: realclean + rm -f $(YACCPAR) + ################################################################################ check: $(THIS)$x $(SHELL) $(testdir)/run_test.sh $(testdir) @@ -167,7 +159,7 @@ tags: $(H_FILES) $(C_FILES) $(CTAGS) $(C_FILES) $(H_FILES) lint: $(C_FILES) - $(LINT) $(CPPFLAGS) $(C_FILES) + $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(C_FILES) @MAKE_UPPER_TAGS@TAGS: $(H_FILES) $(C_FILES) @MAKE_UPPER_TAGS@ $(ETAGS) $(C_FILES) $(H_FILES) @@ -175,9 +167,9 @@ lint: $(C_FILES) depend: makedepend -- $(CPPFLAGS) -- $(C_FILES) -$(OBJS) : defs.h +$(OBJS) : defs.h makefile main$o \ -skeleton$o : makefile VERSION +$(SKELETON)$o : VERSION # DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/contrib/byacc/mkpar.c b/contrib/byacc/mkpar.c index b2e36ab77..653c20225 100644 --- a/contrib/byacc/mkpar.c +++ b/contrib/byacc/mkpar.c @@ -1,7 +1,18 @@ -/* $Id: mkpar.c,v 1.12 2012/05/26 00:42:18 tom Exp $ */ +/* $Id: mkpar.c,v 1.14 2014/04/01 23:05:37 tom Exp $ */ #include "defs.h" +#define NotSuppressed(p) ((p)->suppressed == 0) + +#if defined(YYBTYACC) +#define MaySuppress(p) ((backtrack ? ((p)->suppressed <= 1) : (p)->suppressed == 0)) + /* suppress the preferred action => enable backtracking */ +#define StartBacktrack(p) if (backtrack && (p) != NULL && NotSuppressed(p)) (p)->suppressed = 1 +#else +#define MaySuppress(p) ((p)->suppressed == 0) +#define StartBacktrack(p) /*nothing */ +#endif + static action *add_reduce(action *actions, int ruleno, int symbol); static action *add_reductions(int stateno, action *actions); static action *get_shifts(int stateno); @@ -190,7 +201,7 @@ unused_rules(void) { for (p = parser[i]; p; p = p->next) { - if (p->action_code == REDUCE && p->suppressed == 0) + if ((p->action_code == REDUCE) && MaySuppress(p)) rules_used[p->number] = 1; } } @@ -225,17 +236,23 @@ remove_conflicts(void) SRcount = 0; RRcount = 0; symbol = -1; +#if defined(YYBTYACC) + pref = NULL; +#endif for (p = parser[i]; p; p = p->next) { if (p->symbol != symbol) { + /* the first parse action for each symbol is the preferred action */ pref = p; symbol = p->symbol; } + /* following conditions handle multiple, i.e., conflicting, parse actions */ else if (i == final_state && symbol == 0) { SRcount++; p->suppressed = 1; + StartBacktrack(pref); } else if (pref != 0 && pref->action_code == SHIFT) { @@ -269,12 +286,14 @@ remove_conflicts(void) { SRcount++; p->suppressed = 1; + StartBacktrack(pref); } } else { RRcount++; p->suppressed = 1; + StartBacktrack(pref); } } SRtotal += SRcount; @@ -329,9 +348,9 @@ sole_reduction(int stateno) ruleno = 0; for (p = parser[stateno]; p; p = p->next) { - if (p->action_code == SHIFT && p->suppressed == 0) + if (p->action_code == SHIFT && MaySuppress(p)) return (0); - else if (p->action_code == REDUCE && p->suppressed == 0) + else if ((p->action_code == REDUCE) && MaySuppress(p)) { if (ruleno > 0 && p->number != ruleno) return (0); diff --git a/contrib/byacc/mstring.c b/contrib/byacc/mstring.c new file mode 100644 index 000000000..dc384e5a3 --- /dev/null +++ b/contrib/byacc/mstring.c @@ -0,0 +1,207 @@ +/* $Id: mstring.c,v 1.6 2014/04/22 23:36:31 tom Exp $ */ + +#include +#include +#include +#include +#include +#include "defs.h" + +/* parameters about string length. HEAD is the starting size and +** HEAD+TAIL should be a power of two */ +#define HEAD 24 +#define TAIL 8 + +#if defined(YYBTYACC) + +static char *buf_ptr; +static size_t buf_len; + +void +msprintf(struct mstring *s, const char *fmt,...) +{ + va_list args; + size_t len; +#ifdef HAVE_VSNPRINTF + int changed; +#endif + + if (!s || !s->base) + return; + + if (buf_len == 0) + { + buf_ptr = malloc(buf_len = 4096); + } + if (buf_ptr == 0) + { + return; + } + +#ifdef HAVE_VSNPRINTF + do + { + va_start(args, fmt); + len = (size_t) vsnprintf(buf_ptr, buf_len, fmt, args); + va_end(args); + if ((changed = (len > buf_len)) != 0) + { + char *new_ptr = realloc(buf_ptr, (buf_len * 3) / 2); + if (new_ptr == 0) + { + free(buf_ptr); + buf_ptr = 0; + return; + } + buf_ptr = new_ptr; + } + } + while (changed); +#else + va_start(args, fmt); + len = (size_t) vsprintf(buf_ptr, fmt, args); + va_end(args); + if (len >= buf_len) + return; +#endif + + if (len > (size_t) (s->end - s->ptr)) + { + char *new_base; + size_t cp = (size_t) (s->ptr - s->base); + size_t cl = (size_t) (s->end - s->base); + size_t nl = cl; + while (len > (nl - cp)) + nl = nl + nl + TAIL; + if ((new_base = realloc(s->base, nl))) + { + s->base = new_base; + s->ptr = s->base + cp; + s->end = s->base + nl; + } + else + { + free(s->base); + s->base = 0; + s->ptr = 0; + s->end = 0; + return; + } + } + memcpy(s->ptr, buf_ptr, len); + s->ptr += len; +} +#endif + +int +mputchar(struct mstring *s, int ch) +{ + if (!s || !s->base) + return ch; + if (s->ptr == s->end) + { + size_t len = (size_t) (s->end - s->base); + if ((s->base = realloc(s->base, len + len + TAIL))) + { + s->ptr = s->base + len; + s->end = s->base + len + len + TAIL; + } + else + { + s->ptr = s->end = 0; + return ch; + } + } + *s->ptr++ = (char)ch; + return ch; +} + +struct mstring * +msnew(void) +{ + struct mstring *n = TMALLOC(struct mstring, 1); + + if (n) + { + if ((n->base = n->ptr = MALLOC(HEAD)) != 0) + { + n->end = n->base + HEAD; + } + else + { + free(n); + n = 0; + } + } + return n; +} + +char * +msdone(struct mstring *s) +{ + char *r = 0; + if (s) + { + mputc(s, 0); + r = s->base; + free(s); + } + return r; +} + +#if defined(YYBTYACC) +/* compare two strings, ignoring whitespace, except between two letters or +** digits (and treat all of these as equal) */ +int +strnscmp(const char *a, const char *b) +{ + while (1) + { + while (isspace(*a)) + a++; + while (isspace(*b)) + b++; + while (*a && *a == *b) + a++, b++; + if (isspace(*a)) + { + if (isalnum(a[-1]) && isalnum(*b)) + break; + } + else if (isspace(*b)) + { + if (isalnum(b[-1]) && isalnum(*a)) + break; + } + else + break; + } + return *a - *b; +} + +unsigned int +strnshash(const char *s) +{ + unsigned int h = 0; + + while (*s) + { + if (!isspace(*s)) + h = (h << 5) - h + (unsigned char)*s; + s++; + } + return h; +} +#endif + +#ifdef NO_LEAKS +void +mstring_leaks(void) +{ +#if defined(YYBTYACC) + free(buf_ptr); + buf_ptr = 0; + buf_len = 0; +#endif +} +#endif diff --git a/contrib/byacc/output.c b/contrib/byacc/output.c index 05c35d829..eb4402d3c 100644 --- a/contrib/byacc/output.c +++ b/contrib/byacc/output.c @@ -1,14 +1,24 @@ -/* $Id: output.c,v 1.45 2013/03/05 00:29:17 tom Exp $ */ +/* $Id: output.c,v 1.67 2014/04/22 23:16:57 tom Exp $ */ #include "defs.h" #define StaticOrR (rflag ? "" : "static ") #define CountLine(fp) (!rflag || ((fp) == code_file)) +#if defined(YYBTYACC) +#define PER_STATE 3 +#else +#define PER_STATE 2 +#endif + static int nvectors; static int nentries; static Value_t **froms; static Value_t **tos; +#if defined(YYBTYACC) +static Value_t *conflicts = NULL; +static Value_t nconflicts = 0; +#endif static Value_t *tally; static Value_t *width; static Value_t *state_count; @@ -19,7 +29,7 @@ static int maxtable; static Value_t *table; static Value_t *check; static int lowzero; -static int high; +static long high; static void putc_code(FILE * fp, int c) @@ -49,7 +59,7 @@ write_code_lineno(FILE * fp) if (!lflag && (fp == code_file)) { ++outline; - fprintf(fp, line_format, outline, code_file_name); + fprintf(fp, line_format, outline + 1, code_file_name); } } @@ -105,6 +115,9 @@ output_prefix(FILE * fp) define_prefixed(fp, "yylhs"); define_prefixed(fp, "yylen"); define_prefixed(fp, "yydefred"); +#if defined(YYBTYACC) + define_prefixed(fp, "yystos"); +#endif define_prefixed(fp, "yydgoto"); define_prefixed(fp, "yysindex"); define_prefixed(fp, "yyrindex"); @@ -113,6 +126,22 @@ output_prefix(FILE * fp) define_prefixed(fp, "yycheck"); define_prefixed(fp, "yyname"); define_prefixed(fp, "yyrule"); +#if defined(YYBTYACC) + if (locations) + { + define_prefixed(fp, "yyloc"); + define_prefixed(fp, "yylloc"); + } + putc_code(fp, '\n'); + putl_code(fp, "#if YYBTYACC\n"); + + define_prefixed(fp, "yycindex"); + define_prefixed(fp, "yyctable"); + + putc_code(fp, '\n'); + putl_code(fp, "#endif /* YYBTYACC */\n"); + putc_code(fp, '\n'); +#endif } if (CountLine(fp)) ++outline; @@ -148,7 +177,7 @@ start_int_table(const char *name, int value) if (need < 6) need = 6; fprintf(output_file, - "%sconst short %s%s[] = {%*d,", + "%sconst YYINT %s%s[] = {%*d,", StaticOrR, symbol_prefix, name, need, value); } @@ -156,8 +185,8 @@ static void start_str_table(const char *name) { fprintf(output_file, - "%sconst char *%s%s[] = {", - StaticOrR, "yy", name); + "%sconst char *const %s%s[] = {", + StaticOrR, symbol_prefix, name); output_newline(); } @@ -168,12 +197,23 @@ end_table(void) output_line("};"); } +static void +output_YYINT_typedef(FILE * fp) +{ + /* generate the type used to index the various parser tables */ + if (CountLine(fp)) + ++outline; + fprintf(fp, "typedef %s YYINT;\n", CONCAT1("", YYINT)); +} + static void output_rule_data(void) { int i; int j; + output_YYINT_typedef(output_file); + start_int_table("lhs", symbol_value[start_symbol]); j = 10; @@ -233,27 +273,123 @@ output_yydefred(void) end_table(); } +#if defined(YYBTYACC) +static void +output_accessing_symbols(void) +{ + int i, j; + int *translate; + + if (nstates != 0) + { + translate = TMALLOC(int, nstates); + NO_SPACE(translate); + + for (i = 0; i < nstates; ++i) + { + int gsymb = accessing_symbol[i]; + + translate[i] = symbol_pval[gsymb]; + } + + /* yystos[] may be unused, depending on compile-time defines */ + start_int_table("stos", translate[0]); + + j = 10; + for (i = 1; i < nstates; ++i) + { + if (j < 10) + ++j; + else + { + output_newline(); + j = 1; + } + + output_int(translate[i]); + } + + end_table(); + FREE(translate); + } +} + +static Value_t +find_conflict_base(int cbase) +{ + int i, j; + + for (i = 0; i < cbase; i++) + { + for (j = 0; j + cbase < nconflicts; j++) + { + if (conflicts[i + j] != conflicts[cbase + j]) + break; + } + if (j + cbase >= nconflicts) + break; + } + return (Value_t) i; +} +#endif + static void token_actions(void) { int i, j; Value_t shiftcount, reducecount; +#if defined(YYBTYACC) + Value_t conflictcount = 0; + Value_t csym = -1; + Value_t cbase = 0; +#endif int max, min; Value_t *actionrow, *r, *s; action *p; - actionrow = NEW2(2 * ntokens, Value_t); + actionrow = NEW2(PER_STATE * ntokens, Value_t); for (i = 0; i < nstates; ++i) { if (parser[i]) { - for (j = 0; j < 2 * ntokens; ++j) + for (j = 0; j < PER_STATE * ntokens; ++j) actionrow[j] = 0; shiftcount = 0; reducecount = 0; +#if defined(YYBTYACC) + if (backtrack) + { + conflictcount = 0; + csym = -1; + cbase = nconflicts; + } +#endif for (p = parser[i]; p; p = p->next) { +#if defined(YYBTYACC) + if (backtrack) + { + if (csym != -1 && csym != p->symbol) + { + conflictcount++; + conflicts[nconflicts++] = -1; + j = find_conflict_base(cbase); + actionrow[csym + 2 * ntokens] = (Value_t) (j + 1); + if (j == cbase) + { + cbase = nconflicts; + } + else + { + if (conflicts[cbase] == -1) + cbase++; + nconflicts = cbase; + } + csym = -1; + } + } +#endif if (p->suppressed == 0) { if (p->action_code == SHIFT) @@ -267,17 +403,65 @@ token_actions(void) actionrow[p->symbol + ntokens] = p->number; } } +#if defined(YYBTYACC) + else if (backtrack && p->suppressed == 1) + { + csym = p->symbol; + if (p->action_code == SHIFT) + { + conflicts[nconflicts++] = p->number; + } + else if (p->action_code == REDUCE && p->number != defred[i]) + { + if (cbase == nconflicts) + { + if (cbase) + cbase--; + else + conflicts[nconflicts++] = -1; + } + conflicts[nconflicts++] = (Value_t) (p->number - 2); + } + } +#endif + } +#if defined(YYBTYACC) + if (backtrack && csym != -1) + { + conflictcount++; + conflicts[nconflicts++] = -1; + j = find_conflict_base(cbase); + actionrow[csym + 2 * ntokens] = (Value_t) (j + 1); + if (j == cbase) + { + cbase = nconflicts; + } + else + { + if (conflicts[cbase] == -1) + cbase++; + nconflicts = cbase; + } } +#endif tally[i] = shiftcount; tally[nstates + i] = reducecount; +#if defined(YYBTYACC) + if (backtrack) + tally[2 * nstates + i] = conflictcount; +#endif width[i] = 0; width[nstates + i] = 0; +#if defined(YYBTYACC) + if (backtrack) + width[2 * nstates + i] = 0; +#endif if (shiftcount > 0) { froms[i] = r = NEW2(shiftcount, Value_t); tos[i] = s = NEW2(shiftcount, Value_t); - min = MAXSHORT; + min = MAXYYINT; max = 0; for (j = 0; j < ntokens; ++j) { @@ -297,7 +481,7 @@ token_actions(void) { froms[nstates + i] = r = NEW2(reducecount, Value_t); tos[nstates + i] = s = NEW2(reducecount, Value_t); - min = MAXSHORT; + min = MAXYYINT; max = 0; for (j = 0; j < ntokens; ++j) { @@ -313,6 +497,28 @@ token_actions(void) } width[nstates + i] = (Value_t) (max - min + 1); } +#if defined(YYBTYACC) + if (backtrack && conflictcount > 0) + { + froms[2 * nstates + i] = r = NEW2(conflictcount, Value_t); + tos[2 * nstates + i] = s = NEW2(conflictcount, Value_t); + min = MAXYYINT; + max = 0; + for (j = 0; j < ntokens; ++j) + { + if (actionrow[2 * ntokens + j]) + { + if (min > symbol_value[j]) + min = symbol_value[j]; + if (max < symbol_value[j]) + max = symbol_value[j]; + *r++ = symbol_value[j]; + *s++ = (Value_t) (actionrow[2 * ntokens + j] - 1); + } + } + width[2 * nstates + i] = (Value_t) (max - min + 1); + } +#endif } } FREE(actionrow); @@ -377,7 +583,7 @@ save_column(int symbol, int default_state) if (count == 0) return; - symno = symbol_value[symbol] + 2 * nstates; + symno = symbol_value[symbol] + PER_STATE * nstates; froms[symno] = sp1 = sp = NEW2(count, Value_t); tos[symno] = sp2 = NEW2(count, Value_t); @@ -476,6 +682,11 @@ sort_actions(void) /* Matching_vector is poorly designed. The test could easily be made */ /* faster. Also, it depends on the vectors being in a specific */ /* order. */ +#if defined(YYBTYACC) +/* */ +/* Not really any point in checking for matching conflicts -- it is */ +/* extremely unlikely to occur, and conflicts are (hopefully) rare. */ +#endif static int matching_vector(int vector) @@ -639,9 +850,11 @@ pack_table(void) FREE(tos[i]); } - FREE(froms); - FREE(tos); - FREE(pos); + DO_FREE(froms); + DO_FREE(tos); + DO_FREE(tally); + DO_FREE(width); + DO_FREE(pos); } static void @@ -685,10 +898,32 @@ output_base(void) end_table(); - start_int_table("gindex", base[2 * nstates]); +#if defined(YYBTYACC) + output_line("#if YYBTYACC"); + start_int_table("cindex", base[2 * nstates]); j = 10; - for (i = 2 * nstates + 1; i < nvectors - 1; i++) + for (i = 2 * nstates + 1; i < 3 * nstates; i++) + { + if (j >= 10) + { + output_newline(); + j = 1; + } + else + ++j; + + output_int(base[i]); + } + + end_table(); + output_line("#endif"); +#endif + + start_int_table("gindex", base[PER_STATE * nstates]); + + j = 10; + for (i = PER_STATE * nstates + 1; i < nvectors - 1; i++) { if (j >= 10) { @@ -711,8 +946,15 @@ output_table(void) int i; int j; + if (high >= MAXYYINT) + { + fprintf(stderr, "YYTABLESIZE: %ld\n", high); + fprintf(stderr, "Table is longer than %d elements.\n", MAXYYINT); + done(1); + } + ++outline; - fprintf(code_file, "#define YYTABLESIZE %d\n", high); + fprintf(code_file, "#define YYTABLESIZE %ld\n", high); start_int_table("table", table[0]); j = 10; @@ -759,16 +1001,54 @@ output_check(void) FREE(check); } +#if defined(YYBTYACC) +static void +output_ctable(void) +{ + int i; + int j; + + if (conflicts) + { + output_line("#if YYBTYACC"); + start_int_table("ctable", conflicts[0]); + + j = 10; + for (i = 1; i < nconflicts; i++) + { + if (j >= 10) + { + output_newline(); + j = 1; + } + else + ++j; + + output_int(conflicts[i]); + } + + end_table(); + output_line("#endif"); + FREE(conflicts); + } +} +#endif + static void output_actions(void) { - nvectors = 2 * nstates + nvars; + nvectors = PER_STATE * nstates + nvars; froms = NEW2(nvectors, Value_t *); tos = NEW2(nvectors, Value_t *); tally = NEW2(nvectors, Value_t); width = NEW2(nvectors, Value_t); +#if defined(YYBTYACC) + if (backtrack && (SRtotal + RRtotal) != 0) + conflicts = NEW2(4 * (SRtotal + RRtotal), Value_t); +#endif + token_actions(); FREE(lookaheads); FREE(LA); @@ -785,6 +1065,9 @@ output_actions(void) output_base(); output_table(); output_check(); +#if defined(YYBTYACC) + output_ctable(); +#endif } static int @@ -818,6 +1101,24 @@ is_C_identifier(char *name) return (1); } +#if USE_HEADER_GUARDS +static void +start_defines_file(void) +{ + fprintf(defines_file, "#ifndef _%s_defines_h_\n", symbol_prefix); + fprintf(defines_file, "#define _%s_defines_h_\n\n", symbol_prefix); +} + +static void +end_defines_file(void) +{ + fprintf(defines_file, "\n#endif /* _%s_defines_h_ */\n", symbol_prefix); +} +#else +#define start_defines_file() /* nothing */ +#define end_defines_file() /* nothing */ +#endif + static void output_defines(FILE * fp) { @@ -865,7 +1166,7 @@ output_defines(FILE * fp) { rewind(union_file); while ((c = getc(union_file)) != EOF) - putc(c, fp); + putc_code(fp, c); } fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix); } @@ -895,7 +1196,7 @@ output_stored_text(FILE * fp) static void output_debug(void) { - int i, j, k, max; + int i, j, k, max, maxtok; const char **symnam; const char *s; @@ -914,30 +1215,69 @@ output_debug(void) fprintf(output_file, "#endif\n"); } - max = 0; - for (i = 2; i < ntokens; ++i) - if (symbol_value[i] > max) - max = symbol_value[i]; + maxtok = 0; + for (i = 0; i < ntokens; ++i) + if (symbol_value[i] > maxtok) + maxtok = symbol_value[i]; + + /* symbol_value[$accept] = -1 */ + /* symbol_value[] = 0 */ + /* remaining non-terminals start at 1 */ + max = maxtok; + for (i = ntokens; i < nsyms; ++i) + if (((maxtok + 1) + (symbol_value[i] + 1)) > max) + max = (maxtok + 1) + (symbol_value[i] + 1); + + ++outline; + fprintf(code_file, "#define YYMAXTOKEN %d\n", maxtok); ++outline; - fprintf(code_file, "#define YYMAXTOKEN %d\n", max); + fprintf(code_file, "#define YYUNDFTOKEN %d\n", max + 1); - symnam = TMALLOC(const char *, max + 1); + ++outline; + fprintf(code_file, "#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? " + "YYUNDFTOKEN : (a))\n"); + + symnam = TMALLOC(const char *, max + 2); NO_SPACE(symnam); - /* Note that it is not necessary to initialize the element */ + /* Note that it is not necessary to initialize the element */ /* symnam[max]. */ +#if defined(YYBTYACC) for (i = 0; i < max; ++i) symnam[i] = 0; + for (i = nsyms - 1; i >= 0; --i) + symnam[symbol_pval[i]] = symbol_name[i]; + symnam[max + 1] = "illegal-symbol"; +#else + for (i = 0; i <= max; ++i) + symnam[i] = 0; for (i = ntokens - 1; i >= 2; --i) symnam[symbol_value[i]] = symbol_name[i]; symnam[0] = "end-of-file"; + symnam[max + 1] = "illegal-symbol"; +#endif - output_line("#if YYDEBUG"); + /* + * bison's yytname[] array is roughly the same as byacc's yyname[] array. + * The difference is that byacc does not predefine "$undefined". + * + * If the grammar declares "%token-table", define symbol "yytname" so + * an application such as ntpd can build. + */ + if (token_table) + { + output_line("#undef yytname"); + output_line("#define yytname yyname"); + } + else + { + output_line("#if YYDEBUG"); + } start_str_table("name"); j = 80; - for (i = 0; i <= max; ++i) + for (i = 0; i <= max + 1; ++i) { if ((s = symnam[i]) != 0) { @@ -1058,6 +1398,8 @@ output_debug(void) end_table(); FREE(symnam); + if (token_table) + output_line("#if YYDEBUG"); start_str_table("rule"); for (i = 2; i < nrules; ++i) { @@ -1112,13 +1454,34 @@ output_debug(void) output_line("#endif"); } +#if defined(YYBTYACC) +static void +output_backtracking_parser(FILE * fp) +{ + putl_code(fp, "#undef YYBTYACC\n"); +#if defined(YYBTYACC) + if (backtrack) + { + putl_code(fp, "#define YYBTYACC 1\n"); + putl_code(fp, + "#define YYDEBUGSTR (yytrial ? YYPREFIX \"debug(trial)\" : YYPREFIX \"debug\")\n"); + } + else +#endif + { + putl_code(fp, "#define YYBTYACC 0\n"); + putl_code(fp, "#define YYDEBUGSTR YYPREFIX \"debug\"\n"); + } +} +#endif + static void output_pure_parser(FILE * fp) { putc_code(fp, '\n'); if (fp == code_file) - outline += 1; + ++outline; fprintf(fp, "#define YYPURE %d\n", pure_parser); putc_code(fp, '\n'); } @@ -1129,12 +1492,35 @@ output_stype(FILE * fp) if (!unionized && ntags == 0) { putc_code(fp, '\n'); - putl_code(fp, "#ifndef YYSTYPE\n"); + putl_code(fp, "#if " + "! defined(YYSTYPE) && " + "! defined(YYSTYPE_IS_DECLARED)\n"); + putl_code(fp, "/* Default: YYSTYPE is the semantic value type. */\n"); putl_code(fp, "typedef int YYSTYPE;\n"); + putl_code(fp, "# define YYSTYPE_IS_DECLARED 1\n"); putl_code(fp, "#endif\n"); } } +#if defined(YYBTYACC) +static void +output_ltype(FILE * fp) +{ + putc_code(fp, '\n'); + putl_code(fp, "#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED\n"); + putl_code(fp, "/* Default: YYLTYPE is the text position type. */\n"); + putl_code(fp, "typedef struct YYLTYPE\n"); + putl_code(fp, "{\n"); + putl_code(fp, " int first_line;\n"); + putl_code(fp, " int first_column;\n"); + putl_code(fp, " int last_line;\n"); + putl_code(fp, " int last_column;\n"); + putl_code(fp, "} YYLTYPE;\n"); + putl_code(fp, "#define YYLTYPE_IS_DECLARED 1\n"); + putl_code(fp, "#endif\n"); +} +#endif + static void output_trailing_text(void) { @@ -1208,7 +1594,7 @@ output_semantic_actions(void) static void output_parse_decl(FILE * fp) { - putl_code(fp, "\n"); + putc_code(fp, '\n'); putl_code(fp, "/* compatibility with bison */\n"); putl_code(fp, "#ifdef YYPARSE_PARAM\n"); putl_code(fp, "/* compatibility with FreeBSD */\n"); @@ -1238,19 +1624,45 @@ output_parse_decl(FILE * fp) static void output_lex_decl(FILE * fp) { - putl_code(fp, "\n"); + putc_code(fp, '\n'); putl_code(fp, "/* Parameters sent to lex. */\n"); putl_code(fp, "#ifdef YYLEX_PARAM\n"); if (pure_parser) { putl_code(fp, "# ifdef YYLEX_PARAM_TYPE\n"); - putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval," - " YYLEX_PARAM_TYPE YYLEX_PARAM)\n"); +#if defined(YYBTYACC) + if (locations) + { + putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLTYPE *yylloc," + " YYLEX_PARAM_TYPE YYLEX_PARAM)\n"); + } + else +#endif + { + putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval," + " YYLEX_PARAM_TYPE YYLEX_PARAM)\n"); + } putl_code(fp, "# else\n"); - putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval," - " void * YYLEX_PARAM)\n"); +#if defined(YYBTYACC) + if (locations) + { + putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLTYPE *yylloc," + " void * YYLEX_PARAM)\n"); + } + else +#endif + { + putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval," + " void * YYLEX_PARAM)\n"); + } putl_code(fp, "# endif\n"); - putl_code(fp, "# define YYLEX yylex(&yylval, YYLEX_PARAM)\n"); +#if defined(YYBTYACC) + if (locations) + putl_code(fp, + "# define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)\n"); + else +#endif + putl_code(fp, "# define YYLEX yylex(&yylval, YYLEX_PARAM)\n"); } else { @@ -1261,25 +1673,49 @@ output_lex_decl(FILE * fp) if (pure_parser && lex_param) { param *p; - puts_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, "); + +#if defined(YYBTYACC) + if (locations) + puts_code(fp, + "# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLTYPE *yylloc, "); + else +#endif + puts_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, "); for (p = lex_param; p; p = p->next) fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2, p->next ? ", " : ""); putl_code(fp, ")\n"); - puts_code(fp, "# define YYLEX yylex(&yylval, "); +#if defined(YYBTYACC) + if (locations) + puts_code(fp, "# define YYLEX yylex(&yylval, &yylloc, "); + else +#endif + puts_code(fp, "# define YYLEX yylex(&yylval, "); for (p = lex_param; p; p = p->next) fprintf(fp, "%s%s", p->name, p->next ? ", " : ""); putl_code(fp, ")\n"); } else if (pure_parser) { - putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval)\n"); - putl_code(fp, "# define YYLEX yylex(&yylval)\n"); +#if defined(YYBTYACC) + if (locations) + { + putl_code(fp, + "# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLTYPE *yylloc)\n"); + putl_code(fp, "# define YYLEX yylex(&yylval, &yylloc)\n"); + } + else +#endif + { + putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval)\n"); + putl_code(fp, "# define YYLEX yylex(&yylval)\n"); + } } else if (lex_param) { param *p; + puts_code(fp, "# define YYLEX_DECL() yylex("); for (p = lex_param; p; p = p->next) fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2, @@ -1302,38 +1738,100 @@ output_lex_decl(FILE * fp) static void output_error_decl(FILE * fp) { - putl_code(fp, "\n"); + param *p; + + putc_code(fp, '\n'); putl_code(fp, "/* Parameters sent to yyerror. */\n"); - if (parse_param) - { - param *p; + putl_code(fp, "#ifndef YYERROR_DECL\n"); + puts_code(fp, "#define YYERROR_DECL() yyerror("); +#if defined(YYBTYACC) + if (locations) + puts_code(fp, "YYLTYPE loc, "); +#endif + for (p = parse_param; p; p = p->next) + fprintf(fp, "%s %s%s, ", p->type, p->name, p->type2); + putl_code(fp, "const char *s)\n"); + putl_code(fp, "#endif\n"); - putl_code(fp, "#ifndef YYERROR_DECL\n"); - fprintf(fp, "#define YYERROR_DECL() yyerror("); - for (p = parse_param; p; p = p->next) - fprintf(fp, "%s %s%s, ", p->type, p->name, p->type2); - putl_code(fp, "const char *s)\n"); - putl_code(fp, "#endif\n"); + putl_code(fp, "#ifndef YYERROR_CALL\n"); + puts_code(fp, "#define YYERROR_CALL(msg) yyerror("); - putl_code(fp, "#ifndef YYERROR_CALL\n"); - puts_code(fp, "#define YYERROR_CALL(msg) yyerror("); +#if defined(YYBTYACC) + if (locations) + puts_code(fp, "yylloc, "); +#endif + for (p = parse_param; p; p = p->next) + fprintf(fp, "%s, ", p->name); - for (p = parse_param; p; p = p->next) - fprintf(fp, "%s, ", p->name); + putl_code(fp, "msg)\n"); + putl_code(fp, "#endif\n"); +} - putl_code(fp, "msg)\n"); - putl_code(fp, "#endif\n"); - } +#if defined(YYBTYACC) +static void +output_yydestruct_decl(FILE * fp) +{ + putc_code(fp, '\n'); + putl_code(fp, "#ifndef YYDESTRUCT_DECL\n"); +#if defined(YYBTYACC) + if (locations) + putl_code(fp, + "#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)\n"); + else +#endif + putl_code(fp, + "#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val)\n"); + putl_code(fp, "#endif\n"); + putl_code(fp, "#ifndef YYDESTRUCT_CALL\n"); +#if defined(YYBTYACC) + if (locations) + putl_code(fp, + "#define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)\n"); else +#endif + putl_code(fp, + "#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val)\n"); + putl_code(fp, "#endif\n"); +} + +static void +output_yydestruct_impl(void) +{ + int i; + char *s, *destructor_code; + + putc_code(code_file, '\n'); + putl_code(code_file, "/* Release memory associated with symbol. */\n"); + putl_code(code_file, "#if ! defined YYDESTRUCT_IS_DECLARED\n"); + putl_code(code_file, "static void\n"); + putl_code(code_file, "YYDESTRUCT_DECL()\n"); + putl_code(code_file, "{\n"); + putl_code(code_file, " switch (psymb)\n"); + putl_code(code_file, " {\n"); + for (i = 2; i < nsyms; ++i) { - putl_code(fp, "#ifndef YYERROR_DECL\n"); - putl_code(fp, "#define YYERROR_DECL() yyerror(const char *s)\n"); - putl_code(fp, "#endif\n"); - putl_code(fp, "#ifndef YYERROR_CALL\n"); - putl_code(fp, "#define YYERROR_CALL(msg) yyerror(msg)\n"); - putl_code(fp, "#endif\n"); + if ((destructor_code = symbol_destructor[i]) != NULL) + { + ++outline; + fprintf(code_file, "\tcase %d:\n", symbol_pval[i]); + /* comprehend the number of lines in the destructor code */ + for (s = destructor_code; (s = strchr(s, '\n')) != NULL; s++) + ++outline; + puts_code(code_file, destructor_code); + putc_code(code_file, '\n'); + putl_code(code_file, "\tbreak;\n"); + write_code_lineno(code_file); + FREE(destructor_code); + } } + putl_code(code_file, " }\n"); + putl_code(code_file, "}\n"); + putl_code(code_file, "#define YYDESTRUCT_IS_DECLARED 1\n"); + putl_code(code_file, "#endif\n"); + + DO_FREE(symbol_destructor); } +#endif static void free_itemsets(void) @@ -1374,42 +1872,21 @@ free_reductions(void) } } -static void -output_yyerror_call(const char *msg) -{ - FILE *fp = code_file; - - puts_code(fp, " yyerror("); - if (parse_param) - { - param *p; - for (p = parse_param; p; p = p->next) - fprintf(fp, "%s, ", p->name); - } - puts_code(fp, "\""); - puts_code(fp, msg); - putl_code(fp, "\");\n"); -} - static void output_externs(FILE * fp, const char *const section[]) { - int c; int i; const char *s; for (i = 0; (s = section[i]) != 0; ++i) { - if (*s && *s != '#') + /* prefix non-blank lines that don't start with + C pre-processor directives with 'extern ' */ + if (*s && (*s != '#')) fputs("extern\t", fp); - while ((c = *s) != 0) - { - putc(c, fp); - ++s; - } if (fp == code_file) ++outline; - putc('\n', fp); + fprintf(fp, "%s\n", s); } } @@ -1422,8 +1899,15 @@ output(void) free_shifts(); free_reductions(); +#if defined(YYBTYACC) + output_backtracking_parser(output_file); + if (rflag) + output_backtracking_parser(code_file); +#endif + if (iflag) { + write_code_lineno(code_file); ++outline; fprintf(code_file, "#include \"%s\"\n", externs_file_name); fp = externs_file; @@ -1431,14 +1915,25 @@ output(void) else fp = code_file; - output_prefix(iflag ? externs_file : output_file); + output_prefix(fp); output_pure_parser(fp); output_stored_text(fp); output_stype(fp); +#if defined(YYBTYACC) + if (locations) + output_ltype(fp); +#endif output_parse_decl(fp); output_lex_decl(fp); output_error_decl(fp); - write_section(fp, xdecls); +#if defined(YYBTYACC) + if (destructor) + output_yydestruct_decl(fp); +#endif + if (iflag || !rflag) + { + write_section(fp, xdecls); + } if (iflag) { @@ -1464,17 +1959,24 @@ output(void) } if (dflag) + { + start_defines_file(); output_defines(defines_file); + end_defines_file(); + } output_rule_data(); output_yydefred(); +#if defined(YYBTYACC) + output_accessing_symbols(); +#endif output_actions(); free_parser(); output_debug(); if (rflag) { - output_prefix(code_file); write_section(code_file, xdecls); + output_YYINT_typedef(code_file); write_section(code_file, tables); } write_section(code_file, global_vars); @@ -1488,18 +1990,18 @@ output(void) write_section(code_file, hdr_vars); } output_trailing_text(); +#if defined(YYBTYACC) + if (destructor) + output_yydestruct_impl(); +#endif write_section(code_file, body_1); if (pure_parser) { write_section(code_file, body_vars); } write_section(code_file, body_2); - output_yyerror_call("syntax error"); - write_section(code_file, body_3); output_semantic_actions(); write_section(code_file, trailer); - output_yyerror_call("yacc stack overflow"); - write_section(code_file, trailer_2); } #ifdef NO_LEAKS diff --git a/contrib/byacc/package/byacc.spec b/contrib/byacc/package/byacc.spec index bddf72fb7..5444afd4c 100644 --- a/contrib/byacc/package/byacc.spec +++ b/contrib/byacc/package/byacc.spec @@ -1,8 +1,8 @@ Summary: byacc - public domain Berkeley LALR Yacc parser generator %define AppProgram byacc -%define AppVersion 20130304 +%define AppVersion 20140422 %define UseProgram yacc -# $XTermId: byacc.spec,v 1.16 2013/03/05 01:17:35 tom Exp $ +# $XTermId: byacc.spec,v 1.20 2014/04/22 08:13:20 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: 1 diff --git a/contrib/byacc/package/debian/changelog b/contrib/byacc/package/debian/changelog index c5a5ec1a7..efbef7da5 100644 --- a/contrib/byacc/package/debian/changelog +++ b/contrib/byacc/package/debian/changelog @@ -1,3 +1,28 @@ +byacc (20140422) unstable; urgency=low + + * maintenance updates + + -- Thomas E. Dickey Tue, 22 Apr 2014 04:13:20 -0400 + +byacc (20140409) unstable; urgency=low + + * integrate Tom Shield's btyacc-related changes + * add test-cases to fill in gaps reported by lcov + + -- Thomas E. Dickey Wed, 09 Apr 2014 15:53:59 -0400 + +byacc (20140101) unstable; urgency=low + + * yytname[] changes + + -- Thomas E. Dickey Wed, 01 Jan 2014 10:02:12 -0500 + +byacc (20130925) unstable; urgency=low + + * increase default stack-size + + -- Thomas E. Dickey Wed, 25 Sep 2013 18:41:54 -0400 + byacc (20130304) unstable; urgency=low * changes prompted by Richard Mitton bug-report diff --git a/contrib/byacc/package/mingw-byacc.spec b/contrib/byacc/package/mingw-byacc.spec new file mode 100644 index 000000000..0374e9117 --- /dev/null +++ b/contrib/byacc/package/mingw-byacc.spec @@ -0,0 +1,60 @@ +Summary: byacc - public domain Berkeley LALR Yacc parser generator +%define AppProgram byacc +%define AppVersion 20140422 +%define UseProgram yacc +# $XTermId: mingw-byacc.spec,v 1.3 2014/04/22 08:13:20 tom Exp $ +Name: %{AppProgram} +Version: %{AppVersion} +Release: 1 +License: Public Domain, MIT +Group: Applications/Development +URL: ftp://invisible-island.net/%{AppProgram} +Source0: %{AppProgram}-%{AppVersion}.tgz +Packager: Thomas Dickey + +%description +This package provides a parser generator utility that reads a grammar +specification from a file and generates an LR(1) parser for it. The +parsers consist of a set of LALR(1) parsing tables and a driver +routine written in the C programming language. It has a public domain +license which includes the generated C. + +%prep + +%setup -q -n %{AppProgram}-%{AppVersion} + +%build + +INSTALL_PROGRAM='${INSTALL}' \ + ./configure \ + --program-prefix=b \ + --target %{_target_platform} \ + --prefix=%{_prefix} \ + --bindir=%{_bindir} \ + --libdir=%{_libdir} \ + --mandir=%{_mandir} + +make + +%install +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT + +make install DESTDIR=$RPM_BUILD_ROOT +( cd $RPM_BUILD_ROOT%{_bindir} && ln -s %{AppProgram} %{UseProgram} ) + +strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram} + +%clean +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%{_prefix}/bin/%{AppProgram} +%{_prefix}/bin/%{UseProgram} +%{_mandir}/man1/%{AppProgram}.* + +%changelog +# each patch should add its ChangeLog entries here + +* Wed Sep 25 2013 Thomas Dickey +- cloned from byacc.spec diff --git a/contrib/byacc/package/pkgsrc/Makefile b/contrib/byacc/package/pkgsrc/Makefile index 416ea851c..2cb387fd2 100644 --- a/contrib/byacc/package/pkgsrc/Makefile +++ b/contrib/byacc/package/pkgsrc/Makefile @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.9 2008/07/24 17:13:00 tonnerre Exp $ # -DISTNAME= byacc-20050813 +DISTNAME= byacc-20140422 PKGREVISION= 1 CATEGORIES= devel MASTER_SITES= ftp://invisible-island.net/byacc/ diff --git a/contrib/byacc/reader.c b/contrib/byacc/reader.c index 6b24d7d17..8312a6995 100644 --- a/contrib/byacc/reader.c +++ b/contrib/byacc/reader.c @@ -1,4 +1,4 @@ -/* $Id: reader.c,v 1.36 2012/05/26 16:05:41 tom Exp $ */ +/* $Id: reader.c,v 1.47 2014/04/09 21:09:27 tom Exp $ */ #include "defs.h" @@ -9,16 +9,28 @@ #define LINESIZE 100 -#define L_CURL '{' -#define R_CURL '}' +#define L_CURL '{' +#define R_CURL '}' +#define L_PAREN '(' +#define R_PAREN ')' +#define L_BRAC '[' +#define R_BRAC ']' + +/* the maximum number of arguments (inherited attributes) to a non-terminal */ +/* this is a hard limit, but seems more than adequate */ +#define MAXARGS 20 static void start_rule(bucket *bp, int s_lineno); +#if defined(YYBTYACC) +static void copy_destructor(void); +static char *process_destructor_XX(char *code, char *tag); +#endif static char *cache; static int cinc, cache_size; int ntags; -static int tagmax; +static int tagmax, havetags; static char **tag_table; static char saw_eof; @@ -45,6 +57,36 @@ char line_format[] = "#line %d \"%s\"\n"; param *lex_param; param *parse_param; +#if defined(YYBTYACC) +int destructor = 0; /* =1 if at least one %destructor */ + +static bucket *default_destructor[3] = +{0, 0, 0}; + +#define UNTYPED_DEFAULT 0 +#define TYPED_DEFAULT 1 +#define TYPE_SPECIFIED 2 + +static bucket * +lookup_type_destructor(char *tag) +{ + char name[1024] = "\0"; + bucket *bp, **bpp = &default_destructor[TYPE_SPECIFIED]; + + while ((bp = *bpp) != NULL) + { + if (bp->tag == tag) + return (bp); + bpp = &bp->link; + } + + *bpp = bp = make_bucket(strcat(strcpy(name, tag), " destructor")); + bp->tag = tag; + + return (bp); +} +#endif /* defined(YYBTYACC) */ + static void cachec(int c) { @@ -93,10 +135,7 @@ get_line(void) { line[i] = (char)c; if (c == '\n') - { - cptr = line; - return; - } + break; if (++i >= linesize) { linesize += LINESIZE; @@ -108,10 +147,11 @@ get_line(void) { line[i] = '\n'; saw_eof = 1; - cptr = line; - return; + break; } } + cptr = line; + return; } static char * @@ -226,35 +266,45 @@ nextc(void) } } } +/* *INDENT-OFF* */ +static struct keyword +{ + char name[13]; + int token; +} +keywords[] = { + { "binary", NONASSOC }, +#if defined(YYBTYACC) + { "destructor", DESTRUCTOR }, +#endif + { "expect", EXPECT }, + { "expect-rr", EXPECT_RR }, + { "ident", IDENT }, + { "left", LEFT }, + { "lex-param", LEX_PARAM }, +#if defined(YYBTYACC) + { "locations", LOCATIONS }, +#endif + { "nonassoc", NONASSOC }, + { "parse-param", PARSE_PARAM }, + { "pure-parser", PURE_PARSER }, + { "right", RIGHT }, + { "start", START }, + { "term", TOKEN }, + { "token", TOKEN }, + { "token-table", TOKEN_TABLE }, + { "type", TYPE }, + { "union", UNION }, + { "yacc", POSIX_YACC }, +}; +/* *INDENT-ON* */ -/* - * Compare keyword to cached token, treating '_' and '-' the same. Some - * grammars rely upon this misfeature. - */ static int -matchec(const char *name) +compare_keys(const void *a, const void *b) { - const char *p = cache; - const char *q = name; - int code = 0; /* assume mismatch */ - - while (*p != '\0' && *q != '\0') - { - char a = *p++; - char b = *q++; - if (a == '_') - a = '-'; - if (b == '_') - b = '-'; - if (a != b) - break; - if (*p == '\0' && *q == '\0') - { - code = 1; - break; - } - } - return code; + const struct keyword *p = (const struct keyword *)a; + const struct keyword *q = (const struct keyword *)b; + return strcmp(p->name, q->name); } static int @@ -262,6 +312,7 @@ keyword(void) { int c; char *t_cptr = cptr; + struct keyword *key; c = *++cptr; if (isalpha(c)) @@ -277,12 +328,16 @@ keyword(void) } else if (isdigit(c) || c == '-' - || c == '_' || c == '.' || c == '$') { cachec(c); } + else if (c == '_') + { + /* treat keywords spelled with '_' as if it were '-' */ + cachec('-'); + } else { break; @@ -291,34 +346,10 @@ keyword(void) } cachec(NUL); - if (matchec("token") || matchec("term")) - return (TOKEN); - if (matchec("type")) - return (TYPE); - if (matchec("left")) - return (LEFT); - if (matchec("right")) - return (RIGHT); - if (matchec("nonassoc") || matchec("binary")) - return (NONASSOC); - if (matchec("start")) - return (START); - if (matchec("union")) - return (UNION); - if (matchec("ident")) - return (IDENT); - if (matchec("expect")) - return (EXPECT); - if (matchec("expect-rr")) - return (EXPECT_RR); - if (matchec("pure-parser")) - return (PURE_PARSER); - if (matchec("parse-param")) - return (PARSE_PARAM); - if (matchec("lex-param")) - return (LEX_PARAM); - if (matchec("yacc")) - return (POSIX_YACC); + if ((key = bsearch(cache, keywords, + sizeof(keywords) / sizeof(*key), + sizeof(*key), compare_keys))) + return key->token; } else { @@ -337,7 +368,6 @@ keyword(void) return (NONASSOC); } syntax_error(lineno, line, t_cptr); - /*NOTREACHED */ return (-1); } @@ -372,11 +402,93 @@ copy_ident(void) } } +static char * +copy_string(int quote) +{ + struct mstring *temp = msnew(); + int c; + int s_lineno = lineno; + char *s_line = dup_line(); + char *s_cptr = s_line + (cptr - line - 1); + + for (;;) + { + c = *cptr++; + mputc(temp, c); + if (c == quote) + { + FREE(s_line); + return msdone(temp); + } + if (c == '\n') + unterminated_string(s_lineno, s_line, s_cptr); + if (c == '\\') + { + c = *cptr++; + mputc(temp, c); + if (c == '\n') + { + get_line(); + if (line == 0) + unterminated_string(s_lineno, s_line, s_cptr); + } + } + } +} + +static char * +copy_comment(void) +{ + struct mstring *temp = msnew(); + int c; + + c = *cptr; + if (c == '/') + { + mputc(temp, '*'); + while ((c = *++cptr) != '\n') + { + mputc(temp, c); + if (c == '*' && cptr[1] == '/') + mputc(temp, ' '); + } + mputc(temp, '*'); + mputc(temp, '/'); + } + else if (c == '*') + { + int c_lineno = lineno; + char *c_line = dup_line(); + char *c_cptr = c_line + (cptr - line - 1); + + mputc(temp, c); + ++cptr; + for (;;) + { + c = *cptr++; + mputc(temp, c); + if (c == '*' && *cptr == '/') + { + mputc(temp, '/'); + ++cptr; + FREE(c_line); + return msdone(temp); + } + if (c == '\n') + { + get_line(); + if (line == 0) + unterminated_comment(c_lineno, c_line, c_cptr); + } + } + } + return msdone(temp); +} + static void copy_text(void) { int c; - int quote; FILE *f = text_file; int need_newline = 0; int t_lineno = lineno; @@ -397,7 +509,6 @@ copy_text(void) switch (c) { case '\n': - next_line: putc('\n', f); need_newline = 0; get_line(); @@ -407,82 +518,21 @@ copy_text(void) case '\'': case '"': + putc(c, f); { - int s_lineno = lineno; - char *s_line = dup_line(); - char *s_cptr = s_line + (cptr - line - 1); - - quote = c; - putc(c, f); - for (;;) - { - c = *cptr++; - putc(c, f); - if (c == quote) - { - need_newline = 1; - FREE(s_line); - goto loop; - } - if (c == '\n') - unterminated_string(s_lineno, s_line, s_cptr); - if (c == '\\') - { - c = *cptr++; - putc(c, f); - if (c == '\n') - { - get_line(); - if (line == 0) - unterminated_string(s_lineno, s_line, s_cptr); - } - } - } + char *s = copy_string(c); + fputs(s, f); + free(s); } + need_newline = 1; + goto loop; case '/': putc(c, f); - need_newline = 1; - c = *cptr; - if (c == '/') { - putc('*', f); - while ((c = *++cptr) != '\n') - { - if (c == '*' && cptr[1] == '/') - fprintf(f, "* "); - else - putc(c, f); - } - fprintf(f, "*/"); - goto next_line; - } - if (c == '*') - { - int c_lineno = lineno; - char *c_line = dup_line(); - char *c_cptr = c_line + (cptr - line - 1); - - putc('*', f); - ++cptr; - for (;;) - { - c = *cptr++; - putc(c, f); - if (c == '*' && *cptr == '/') - { - putc('/', f); - ++cptr; - FREE(c_line); - goto loop; - } - if (c == '\n') - { - get_line(); - if (line == 0) - unterminated_comment(c_lineno, c_line, c_cptr); - } - } + char *s = copy_comment(); + fputs(s, f); + free(s); } need_newline = 1; goto loop; @@ -526,7 +576,6 @@ static void copy_union(void) { int c; - int quote; int depth; int u_lineno = lineno; char *u_line = dup_line(); @@ -554,7 +603,6 @@ copy_union(void) switch (c) { case '\n': - next_line: get_line(); if (line == 0) unterminated_union(u_lineno, u_line, u_cptr); @@ -577,81 +625,17 @@ copy_union(void) case '\'': case '"': { - int s_lineno = lineno; - char *s_line = dup_line(); - char *s_cptr = s_line + (cptr - line - 1); - - quote = c; - for (;;) - { - c = *cptr++; - putc_both(c); - if (c == quote) - { - FREE(s_line); - goto loop; - } - if (c == '\n') - unterminated_string(s_lineno, s_line, s_cptr); - if (c == '\\') - { - c = *cptr++; - putc_both(c); - if (c == '\n') - { - get_line(); - if (line == 0) - unterminated_string(s_lineno, s_line, s_cptr); - } - } - } + char *s = copy_string(c); + puts_both(s); + free(s); } + goto loop; case '/': - c = *cptr; - if (c == '/') - { - putc_both('*'); - while ((c = *++cptr) != '\n') - { - if (c == '*' && cptr[1] == '/') - { - puts_both("* "); - } - else - { - putc_both(c); - } - } - puts_both("*/\n"); - goto next_line; - } - if (c == '*') { - int c_lineno = lineno; - char *c_line = dup_line(); - char *c_cptr = c_line + (cptr - line - 1); - - putc_both('*'); - ++cptr; - for (;;) - { - c = *cptr++; - putc_both(c); - if (c == '*' && *cptr == '/') - { - putc_both('/'); - ++cptr; - FREE(c_line); - goto loop; - } - if (c == '\n') - { - get_line(); - if (line == 0) - unterminated_comment(c_lineno, c_line, c_cptr); - } - } + char *s = copy_comment(); + puts_both(s); + free(s); } goto loop; @@ -675,20 +659,20 @@ copy_param(int k) c = nextc(); if (c == EOF) unexpected_EOF(); - if (c != '{') + if (c != L_CURL) goto out; cptr++; c = nextc(); if (c == EOF) unexpected_EOF(); - if (c == '}') + if (c == R_CURL) goto out; buf = TMALLOC(char, linesize); NO_SPACE(buf); - for (i = 0; (c = *cptr++) != '}'; i++) + for (i = 0; (c = *cptr++) != R_CURL; i++) { if (c == '\0') missing_brace(); @@ -701,7 +685,7 @@ copy_param(int k) goto out; buf[i--] = '\0'; - while (i >= 0 && isspace(UCH(buf[i]))) + while (i > 0 && isspace(UCH(buf[i]))) buf[i--] = '\0'; if (buf[i] == ']') @@ -724,8 +708,8 @@ copy_param(int k) type2 = i + 1; } - while (i >= 0 && (isalnum(UCH(buf[i])) || - UCH(buf[i]) == '_')) + while (i > 0 && (isalnum(UCH(buf[i])) || + UCH(buf[i]) == '_')) i--; if (!isspace(UCH(buf[i])) && buf[i] != '*') @@ -1014,11 +998,41 @@ get_number(void) } static char * -get_tag(void) +cache_tag(char *tag, size_t len) { - int c; int i; char *s; + + for (i = 0; i < ntags; ++i) + { + if (strncmp(tag, tag_table[i], len) == 0 && + tag_table[i][len] == NUL) + return (tag_table[i]); + } + + if (ntags >= tagmax) + { + tagmax += 16; + tag_table = + (tag_table + ? TREALLOC(char *, tag_table, tagmax) + : TMALLOC(char *, tagmax)); + NO_SPACE(tag_table); + } + + s = TMALLOC(char, len + 1); + NO_SPACE(s); + + strncpy(s, tag, len); + s[len] = 0; + tag_table[ntags++] = s; + return s; +} + +static char * +get_tag(void) +{ + int c; int t_lineno = lineno; char *t_line = dup_line(); char *t_cptr = t_line + (cptr - line); @@ -1046,34 +1060,22 @@ get_tag(void) illegal_tag(t_lineno, t_line, t_cptr); ++cptr; - for (i = 0; i < ntags; ++i) - { - if (strcmp(cache, tag_table[i]) == 0) - { - FREE(t_line); - return (tag_table[i]); - } - } - - if (ntags >= tagmax) - { - tagmax += 16; - tag_table = - (tag_table - ? TREALLOC(char *, tag_table, tagmax) - : TMALLOC(char *, tagmax)); - NO_SPACE(tag_table); - } + FREE(t_line); + havetags = 1; + return cache_tag(cache, (size_t) cinc); +} - s = TMALLOC(char, cinc); - NO_SPACE(s); +#if defined(YYBTYACC) +static char * +scan_id(void) +{ + char *b = cptr; - strcpy(s, cache); - tag_table[ntags] = s; - ++ntags; - FREE(t_line); - return (s); + while (isalnum(*cptr) || *cptr == '_' || *cptr == '$') + cptr++; + return cache_tag(b, (size_t) (cptr - b)); } +#endif static void declare_tokens(int assoc) @@ -1191,33 +1193,88 @@ declare_expect(int assoc) } } +#if defined(YYBTYACC) +static void +declare_argtypes(bucket *bp) +{ + char *tags[MAXARGS]; + int args = 0, c; + + if (bp->args >= 0) + retyped_warning(bp->name); + cptr++; /* skip open paren */ + for (;;) + { + c = nextc(); + if (c == EOF) + unexpected_EOF(); + if (c != '<') + syntax_error(lineno, line, cptr); + tags[args++] = get_tag(); + c = nextc(); + if (c == R_PAREN) + break; + if (c == EOF) + unexpected_EOF(); + } + cptr++; /* skip close paren */ + bp->args = args; + bp->argnames = TMALLOC(char *, args); + NO_SPACE(bp->argnames); + bp->argtags = CALLOC(sizeof(char *), args + 1); + NO_SPACE(bp->argtags); + while (--args >= 0) + { + bp->argtags[args] = tags[args]; + bp->argnames[args] = NULL; + } +} +#endif + static void declare_types(void) { int c; bucket *bp; - char *tag; + char *tag = NULL; c = nextc(); if (c == EOF) unexpected_EOF(); - if (c != '<') - syntax_error(lineno, line, cptr); - tag = get_tag(); + if (c == '<') + tag = get_tag(); for (;;) { c = nextc(); + if (c == EOF) + unexpected_EOF(); if (isalpha(c) || c == '_' || c == '.' || c == '$') + { bp = get_name(); +#if defined(YYBTYACC) + if (nextc() == L_PAREN) + declare_argtypes(bp); + else + bp->args = 0; +#endif + } else if (c == '\'' || c == '"') + { bp = get_literal(); +#if defined(YYBTYACC) + bp->args = 0; +#endif + } else return; - if (bp->tag && tag != bp->tag) - retyped_warning(bp->name); - bp->tag = tag; + if (tag) + { + if (bp->tag && tag != bp->tag) + retyped_warning(bp->name); + bp->tag = tag; + } } } @@ -1302,6 +1359,21 @@ read_declarations(void) copy_param(k); break; + case TOKEN_TABLE: + token_table = 1; + break; + +#if defined(YYBTYACC) + case LOCATIONS: + locations = 1; + break; + + case DESTRUCTOR: + destructor = 1; + copy_destructor(); + break; +#endif + case POSIX_YACC: /* noop for bison compatibility. byacc is already designed to be posix * yacc compatible. */ @@ -1372,6 +1444,330 @@ expand_rules(void) NO_SPACE(rassoc); } +/* set immediately prior to where copy_args() could be called, and incremented by + the various routines that will rescan the argument list as appropriate */ +static int rescan_lineno; +#if defined(YYBTYACC) + +static char * +copy_args(int *alen) +{ + struct mstring *s = msnew(); + int depth = 0, len = 1; + char c, quote = 0; + int a_lineno = lineno; + char *a_line = dup_line(); + char *a_cptr = a_line + (cptr - line - 1); + + while ((c = *cptr++) != R_PAREN || depth || quote) + { + if (c == ',' && !quote && !depth) + { + len++; + mputc(s, 0); + continue; + } + mputc(s, c); + if (c == '\n') + { + get_line(); + if (!line) + { + if (quote) + unterminated_string(a_lineno, a_line, a_cptr); + else + unterminated_arglist(a_lineno, a_line, a_cptr); + } + } + else if (quote) + { + if (c == quote) + quote = 0; + else if (c == '\\') + { + if (*cptr != '\n') + mputc(s, *cptr++); + } + } + else + { + if (c == L_PAREN) + depth++; + else if (c == R_PAREN) + depth--; + else if (c == '\"' || c == '\'') + quote = c; + } + } + if (alen) + *alen = len; + FREE(a_line); + return msdone(s); +} + +static char * +parse_id(char *p, char **save) +{ + char *b; + + while (isspace(*p)) + if (*p++ == '\n') + rescan_lineno++; + if (!isalpha(*p) && *p != '_') + return NULL; + b = p; + while (isalnum(*p) || *p == '_' || *p == '$') + p++; + if (save) + { + *save = cache_tag(b, (size_t) (p - b)); + } + return p; +} + +static char * +parse_int(char *p, int *save) +{ + int neg = 0, val = 0; + + while (isspace(*p)) + if (*p++ == '\n') + rescan_lineno++; + if (*p == '-') + { + neg = 1; + p++; + } + if (!isdigit(*p)) + return NULL; + while (isdigit(*p)) + val = val * 10 + *p++ - '0'; + if (neg) + val = -val; + if (save) + *save = val; + return p; +} + +static void +parse_arginfo(bucket *a, char *args, int argslen) +{ + char *p = args, *tmp; + int i, redec = 0; + + if (a->args > 0) + { + if (a->args != argslen) + arg_number_disagree_warning(rescan_lineno, a->name); + redec = 1; + } + else + { + if ((a->args = argslen) == 0) + return; + a->argnames = TMALLOC(char *, argslen); + NO_SPACE(a->argnames); + a->argtags = TMALLOC(char *, argslen); + NO_SPACE(a->argtags); + } + if (!args) + return; + for (i = 0; i < argslen; i++) + { + while (isspace(*p)) + if (*p++ == '\n') + rescan_lineno++; + if (*p++ != '$') + bad_formals(); + while (isspace(*p)) + if (*p++ == '\n') + rescan_lineno++; + if (*p == '<') + { + havetags = 1; + if (!(p = parse_id(p + 1, &tmp))) + bad_formals(); + while (isspace(*p)) + if (*p++ == '\n') + rescan_lineno++; + if (*p++ != '>') + bad_formals(); + if (redec) + { + if (a->argtags[i] != tmp) + arg_type_disagree_warning(rescan_lineno, i + 1, a->name); + } + else + a->argtags[i] = tmp; + } + else if (!redec) + a->argtags[i] = NULL; + if (!(p = parse_id(p, &a->argnames[i]))) + bad_formals(); + while (isspace(*p)) + if (*p++ == '\n') + rescan_lineno++; + if (*p++) + bad_formals(); + } + free(args); +} + +static char * +compile_arg(char **theptr, char *yyvaltag) +{ + char *p = *theptr; + struct mstring *c = msnew(); + int i, j, n; + Value_t *offsets = NULL, maxoffset; + bucket **rhs; + + maxoffset = 0; + n = 0; + for (i = nitems - 1; pitem[i]; --i) + { + n++; + if (pitem[i]->class != ARGUMENT) + maxoffset++; + } + if (maxoffset > 0) + { + offsets = TMALLOC(Value_t, maxoffset + 1); + NO_SPACE(offsets); + } + for (j = 0, i++; i < nitems; i++) + if (pitem[i]->class != ARGUMENT) + offsets[++j] = (Value_t) (i - nitems + 1); + rhs = pitem + nitems - 1; + + if (yyvaltag) + msprintf(c, "yyval.%s = ", yyvaltag); + else + msprintf(c, "yyval = "); + while (*p) + { + if (*p == '$') + { + char *tag = NULL; + if (*++p == '<') + if (!(p = parse_id(++p, &tag)) || *p++ != '>') + illegal_tag(rescan_lineno, NULL, NULL); + if (isdigit(*p) || *p == '-') + { + int val; + if (!(p = parse_int(p, &val))) + dollar_error(rescan_lineno, NULL, NULL); + if (val <= 0) + i = val - n; + else if (val > maxoffset) + { + dollar_warning(rescan_lineno, val); + i = val - maxoffset; + } + else + { + i = offsets[val]; + if (!tag && !(tag = rhs[i]->tag) && havetags) + untyped_rhs(val, rhs[i]->name); + } + msprintf(c, "yystack.l_mark[%d]", i); + if (tag) + msprintf(c, ".%s", tag); + else if (havetags) + unknown_rhs(val); + } + else if (isalpha(*p) || *p == '_') + { + char *arg; + if (!(p = parse_id(p, &arg))) + dollar_error(rescan_lineno, NULL, NULL); + for (i = plhs[nrules]->args - 1; i >= 0; i--) + if (arg == plhs[nrules]->argnames[i]) + break; + if (i < 0) + unknown_arg_warning(rescan_lineno, "$", arg, NULL, NULL); + else if (!tag) + tag = plhs[nrules]->argtags[i]; + msprintf(c, "yystack.l_mark[%d]", i - plhs[nrules]->args + 1 + - n); + if (tag) + msprintf(c, ".%s", tag); + else if (havetags) + untyped_arg_warning(rescan_lineno, "$", arg); + } + else + dollar_error(rescan_lineno, NULL, NULL); + } + else if (*p == '@') + { + at_error(rescan_lineno, NULL, NULL); + } + else + { + if (*p == '\n') + rescan_lineno++; + mputc(c, *p++); + } + } + *theptr = p; + if (maxoffset > 0) + FREE(offsets); + return msdone(c); +} + +#define ARG_CACHE_SIZE 1024 +static struct arg_cache +{ + struct arg_cache *next; + char *code; + int rule; +} + *arg_cache[ARG_CACHE_SIZE]; + +static int +lookup_arg_cache(char *code) +{ + struct arg_cache *entry; + + entry = arg_cache[strnshash(code) % ARG_CACHE_SIZE]; + while (entry) + { + if (!strnscmp(entry->code, code)) + return entry->rule; + entry = entry->next; + } + return -1; +} + +static void +insert_arg_cache(char *code, int rule) +{ + struct arg_cache *entry = NEW(struct arg_cache); + int i; + + NO_SPACE(entry); + i = strnshash(code) % ARG_CACHE_SIZE; + entry->code = code; + entry->rule = rule; + entry->next = arg_cache[i]; + arg_cache[i] = entry; +} + +static void +clean_arg_cache(void) +{ + struct arg_cache *e, *t; + int i; + + for (i = 0; i < ARG_CACHE_SIZE; i++) + { + for (e = arg_cache[i]; (t = e); e = e->next, FREE(t)) + free(e->code); + arg_cache[i] = NULL; + } +} +#endif + static void advance_to_start(void) { @@ -1379,6 +1775,10 @@ advance_to_start(void) bucket *bp; char *s_cptr; int s_lineno; +#if defined(YYBTYACC) + char *args = NULL; + int argslen = 0; +#endif for (;;) { @@ -1419,9 +1819,22 @@ advance_to_start(void) c = nextc(); if (c == EOF) unexpected_EOF(); + rescan_lineno = lineno; /* line# for possible inherited args rescan */ +#if defined(YYBTYACC) + if (c == L_PAREN) + { + ++cptr; + args = copy_args(&argslen); + NO_SPACE(args); + c = nextc(); + } +#endif if (c != ':') syntax_error(lineno, line, cptr); start_rule(bp, s_lineno); +#if defined(YYBTYACC) + parse_arginfo(bp, args, argslen); +#endif ++cptr; } @@ -1431,6 +1844,8 @@ start_rule(bucket *bp, int s_lineno) if (bp->class == TERM) terminal_lhs(s_lineno); bp->class = NONTERM; + if (!bp->index) + bp->index = nrules; if (nrules >= maxrules) expand_rules(); plhs[nrules] = bp; @@ -1477,9 +1892,13 @@ insert_empty_rule(void) last_symbol->next = bp; last_symbol = bp; bp->tag = plhs[nrules]->tag; - bp->class = NONTERM; + bp->class = ACTION; +#if defined(YYBTYACC) + bp->args = 0; +#endif - if ((nitems += 2) > maxitems) + nitems = (Value_t) (nitems + 2); + if (nitems > maxitems) expand_items(); bpp = pitem + nitems - 1; *bpp-- = bp; @@ -1496,12 +1915,49 @@ insert_empty_rule(void) rassoc[nrules - 1] = TOKEN; } +#if defined(YYBTYACC) +static char * +insert_arg_rule(char *arg, char *tag) +{ + int line_number = rescan_lineno; + char *code = compile_arg(&arg, tag); + int rule = lookup_arg_cache(code); + FILE *f = action_file; + + if (rule < 0) + { + rule = nrules; + insert_arg_cache(code, rule); + fprintf(f, "case %d:\n", rule - 2); + if (!lflag) + fprintf(f, line_format, line_number, input_file_name); + fprintf(f, "%s;\n", code); + fprintf(f, "break;\n"); + insert_empty_rule(); + plhs[rule]->tag = tag; + plhs[rule]->class = ARGUMENT; + } + else + { + if (++nitems > maxitems) + expand_items(); + pitem[nitems - 1] = plhs[rule]; + free(code); + } + return arg + 1; +} +#endif + static void add_symbol(void) { int c; bucket *bp; int s_lineno = lineno; +#if defined(YYBTYACC) + char *args = NULL; + int argslen = 0; +#endif c = *cptr; if (c == '\'' || c == '"') @@ -1510,10 +1966,23 @@ add_symbol(void) bp = get_name(); c = nextc(); + rescan_lineno = lineno; /* line# for possible inherited args rescan */ +#if defined(YYBTYACC) + if (c == L_PAREN) + { + ++cptr; + args = copy_args(&argslen); + NO_SPACE(args); + c = nextc(); + } +#endif if (c == ':') { end_rule(); start_rule(bp, s_lineno); +#if defined(YYBTYACC) + parse_arginfo(bp, args, argslen); +#endif ++cptr; return; } @@ -1522,6 +1991,30 @@ add_symbol(void) insert_empty_rule(); last_was_action = 0; +#if defined(YYBTYACC) + if (bp->args < 0) + bp->args = argslen; + if (argslen == 0 && bp->args > 0 && pitem[nitems - 1] == NULL) + { + int i; + if (plhs[nrules]->args != bp->args) + wrong_number_args_warning("default ", bp->name); + for (i = bp->args - 1; i >= 0; i--) + if (plhs[nrules]->argtags[i] != bp->argtags[i]) + wrong_type_for_arg_warning(i + 1, bp->name); + } + else if (bp->args != argslen) + wrong_number_args_warning("", bp->name); + if (bp->args > 0 && argslen > 0) + { + char *ap; + int i; + for (ap = args, i = 0; i < argslen; i++) + ap = insert_arg_rule(ap, bp->argtags[i]); + free(args); + } +#endif /* defined(YYBTYACC) */ + if (++nitems > maxitems) expand_items(); pitem[nitems - 1] = bp; @@ -1539,20 +2032,34 @@ static void copy_action(void) { int c; - int i, n; + int i, j, n; int depth; - int quote; +#if defined(YYBTYACC) + int trialaction = 0; + int haveyyval = 0; +#endif char *tag; FILE *f = action_file; int a_lineno = lineno; char *a_line = dup_line(); char *a_cptr = a_line + (cptr - line); + Value_t *offsets = NULL, maxoffset; + bucket **rhs; if (last_was_action) insert_empty_rule(); last_was_action = 1; fprintf(f, "case %d:\n", nrules - 2); +#if defined(YYBTYACC) + if (backtrack) + { + if (*cptr != L_BRAC) + fprintf(f, " if (!yytrial)\n"); + else + trialaction = 1; + } +#endif if (!lflag) fprintf(f, line_format, lineno, input_file_name); if (*cptr == '=') @@ -1565,9 +2072,27 @@ copy_action(void) cptr = after_blanks(cptr); } + maxoffset = 0; n = 0; for (i = nitems - 1; pitem[i]; --i) + { ++n; + if (pitem[i]->class != ARGUMENT) + maxoffset++; + } + if (maxoffset > 0) + { + offsets = TMALLOC(Value_t, maxoffset + 1); + NO_SPACE(offsets); + } + for (j = 0, i++; i < nitems; i++) + { + if (pitem[i]->class != ARGUMENT) + { + offsets[++j] = (Value_t) (i - nitems + 1); + } + } + rhs = pitem + nitems - 1; depth = 0; loop: @@ -1593,9 +2118,15 @@ copy_action(void) else if (isdigit(c)) { i = get_number(); - if (i > n) + if (i == 0) + fprintf(f, "yystack.l_mark[%d].%s", -n, tag); + else if (i > maxoffset) + { dollar_warning(d_lineno, i); - fprintf(f, "yystack.l_mark[%d].%s", i - n, tag); + fprintf(f, "yystack.l_mark[%d].%s", i - maxoffset, tag); + } + else if (offsets) + fprintf(f, "yystack.l_mark[%d].%s", offsets[i], tag); FREE(d_line); goto loop; } @@ -1607,12 +2138,27 @@ copy_action(void) FREE(d_line); goto loop; } +#if defined(YYBTYACC) + else if (isalpha(c) || c == '_') + { + char *arg = scan_id(); + for (i = plhs[nrules]->args - 1; i >= 0; i--) + if (arg == plhs[nrules]->argnames[i]) + break; + if (i < 0) + unknown_arg_warning(d_lineno, "$", arg, d_line, d_cptr); + fprintf(f, "yystack.l_mark[%d].%s", i - plhs[nrules]->args + + 1 - n, tag); + FREE(d_line); + goto loop; + } +#endif else dollar_error(d_lineno, d_line, d_cptr); } else if (cptr[1] == '$') { - if (ntags) + if (havetags) { tag = plhs[nrules]->tag; if (tag == 0) @@ -1622,26 +2168,35 @@ copy_action(void) else fprintf(f, "yyval"); cptr += 2; +#if defined(YYBTYACC) + haveyyval = 1; +#endif goto loop; } else if (isdigit(UCH(cptr[1]))) { ++cptr; i = get_number(); - if (ntags) + if (havetags) { - if (i <= 0 || i > n) + if (i <= 0 || i > maxoffset) unknown_rhs(i); - tag = pitem[nitems + i - n - 1]->tag; + tag = rhs[offsets[i]]->tag; if (tag == 0) - untyped_rhs(i, pitem[nitems + i - n - 1]->name); - fprintf(f, "yystack.l_mark[%d].%s", i - n, tag); + untyped_rhs(i, rhs[offsets[i]]->name); + fprintf(f, "yystack.l_mark[%d].%s", offsets[i], tag); } else { - if (i > n) + if (i == 0) + fprintf(f, "yystack.l_mark[%d]", -n); + else if (i > maxoffset) + { dollar_warning(lineno, i); - fprintf(f, "yystack.l_mark[%d]", i - n); + fprintf(f, "yystack.l_mark[%d]", i - maxoffset); + } + else if (offsets) + fprintf(f, "yystack.l_mark[%d]", offsets[i]); } goto loop; } @@ -1649,12 +2204,65 @@ copy_action(void) { cptr += 2; i = get_number(); - if (ntags) + if (havetags) unknown_rhs(-i); fprintf(f, "yystack.l_mark[%d]", -i - n); goto loop; } +#if defined(YYBTYACC) + else if (isalpha(cptr[1]) || cptr[1] == '_') + { + char *arg; + ++cptr; + arg = scan_id(); + for (i = plhs[nrules]->args - 1; i >= 0; i--) + if (arg == plhs[nrules]->argnames[i]) + break; + if (i < 0) + unknown_arg_warning(lineno, "$", arg, line, cptr); + tag = (i < 0 ? NULL : plhs[nrules]->argtags[i]); + fprintf(f, "yystack.l_mark[%d]", i - plhs[nrules]->args + 1 - n); + if (tag) + fprintf(f, ".%s", tag); + else if (havetags) + untyped_arg_warning(lineno, "$", arg); + goto loop; + } +#endif + } +#if defined(YYBTYACC) + if (c == '@') + { + if (!locations) + { + int l_lineno = lineno; + char *l_line = dup_line(); + char *l_cptr = l_line + (cptr - line); + syntax_error(l_lineno, l_line, l_cptr); + } + if (cptr[1] == '$') + { + fprintf(f, "yyloc"); + cptr += 2; + goto loop; + } + else if (isdigit(UCH(cptr[1]))) + { + ++cptr; + i = get_number(); + if (i == 0) + fprintf(f, "yystack.p_mark[%d]", -n); + else if (i > maxoffset) + { + at_warning(lineno, i); + fprintf(f, "yystack.p_mark[%d]", i - maxoffset); + } + else if (offsets) + fprintf(f, "yystack.p_mark[%d]", offsets[i]); + goto loop; + } } +#endif if (isalpha(c) || c == '_' || c == '$') { do @@ -1665,12 +2273,45 @@ copy_action(void) while (isalnum(c) || c == '_' || c == '$'); goto loop; } - putc(c, f); ++cptr; +#if defined(YYBTYACC) + if (backtrack) + { + if (trialaction && c == L_BRAC && depth == 0) + { + ++depth; + putc(L_CURL, f); + goto loop; + } + if (trialaction && c == R_BRAC && depth == 1) + { + --depth; + putc(R_CURL, f); + c = nextc(); + if (c == L_BRAC && !haveyyval) + { + goto loop; + } + if (c == L_CURL && !haveyyval) + { + fprintf(f, " if (!yytrial)\n"); + if (!lflag) + fprintf(f, line_format, lineno, input_file_name); + trialaction = 0; + goto loop; + } + fprintf(f, "\nbreak;\n"); + FREE(a_line); + if (maxoffset > 0) + FREE(offsets); + return; + } + } +#endif + putc(c, f); switch (c) { case '\n': - next_line: get_line(); if (line) goto loop; @@ -1681,8 +2322,22 @@ copy_action(void) goto loop; fprintf(f, "\nbreak;\n"); free(a_line); + if (maxoffset > 0) + FREE(offsets); return; +#if defined(YYBTYACC) + case L_BRAC: + if (backtrack) + ++depth; + goto loop; + + case R_BRAC: + if (backtrack) + --depth; + goto loop; +#endif + case L_CURL: ++depth; goto loop; @@ -1690,83 +2345,326 @@ copy_action(void) case R_CURL: if (--depth > 0) goto loop; +#if defined(YYBTYACC) + if (backtrack) + { + c = nextc(); + if (c == L_BRAC && !haveyyval) + { + trialaction = 1; + goto loop; + } + if (c == L_CURL && !haveyyval) + { + fprintf(f, " if (!yytrial)\n"); + if (!lflag) + fprintf(f, line_format, lineno, input_file_name); + goto loop; + } + } +#endif fprintf(f, "\nbreak;\n"); free(a_line); + if (maxoffset > 0) + FREE(offsets); return; case '\'': case '"': { - int s_lineno = lineno; - char *s_line = dup_line(); - char *s_cptr = s_line + (cptr - line - 1); + char *s = copy_string(c); + fputs(s, f); + free(s); + } + goto loop; - quote = c; - for (;;) + case '/': + { + char *s = copy_comment(); + fputs(s, f); + free(s); + } + goto loop; + + default: + goto loop; + } +} + +#if defined(YYBTYACC) +static void +copy_destructor(void) +{ + int c; + int depth; + char *tag; + bucket *bp; + struct mstring *destructor_text = msnew(); + char *code_text; + int a_lineno; + char *a_line; + char *a_cptr; + + if (!lflag) + msprintf(destructor_text, line_format, lineno, input_file_name); + + cptr = after_blanks(cptr); + if (*cptr == L_CURL) + /* avoid putting curly-braces in first column, to ease editing */ + mputc(destructor_text, '\t'); + else + syntax_error(lineno, line, cptr); + + a_lineno = lineno; + a_line = dup_line(); + a_cptr = a_line + (cptr - line); + + depth = 0; + loop: + c = *cptr; + if (c == '$') + { + if (cptr[1] == '<') + { + int d_lineno = lineno; + char *d_line = dup_line(); + char *d_cptr = d_line + (cptr - line); + + ++cptr; + tag = get_tag(); + c = *cptr; + if (c == '$') { - c = *cptr++; - putc(c, f); - if (c == quote) + msprintf(destructor_text, "(*val).%s", tag); + ++cptr; + FREE(d_line); + goto loop; + } + else + dollar_error(d_lineno, d_line, d_cptr); + } + else if (cptr[1] == '$') + { + /* process '$$' later; replacement is context dependent */ + msprintf(destructor_text, "$$"); + cptr += 2; + goto loop; + } + } + if (c == '@' && cptr[1] == '$') + { + if (!locations) + { + int l_lineno = lineno; + char *l_line = dup_line(); + char *l_cptr = l_line + (cptr - line); + syntax_error(l_lineno, l_line, l_cptr); + } + msprintf(destructor_text, "(*loc)"); + cptr += 2; + goto loop; + } + if (isalpha(c) || c == '_' || c == '$') + { + do + { + mputc(destructor_text, c); + c = *++cptr; + } + while (isalnum(c) || c == '_' || c == '$'); + goto loop; + } + ++cptr; + mputc(destructor_text, c); + switch (c) + { + case '\n': + get_line(); + if (line) + goto loop; + unterminated_action(a_lineno, a_line, a_cptr); + + case L_CURL: + ++depth; + goto loop; + + case R_CURL: + if (--depth > 0) + goto loop; + goto process_symbols; + + case '\'': + case '"': + { + char *s = copy_string(c); + msprintf(destructor_text, "%s", s); + free(s); + } + goto loop; + + case '/': + { + char *s = copy_comment(); + msprintf(destructor_text, "%s", s); + free(s); + } + goto loop; + + default: + goto loop; + } + process_symbols: + code_text = msdone(destructor_text); + for (;;) + { + c = nextc(); + if (c == EOF) + unexpected_EOF(); + if (c == '<') + { + if (cptr[1] == '>') + { /* "no semantic type" default destructor */ + cptr += 2; + if ((bp = default_destructor[UNTYPED_DEFAULT]) == NULL) { - FREE(s_line); - goto loop; + static char untyped_default[] = "<>"; + bp = make_bucket("untyped default"); + bp->tag = untyped_default; + default_destructor[UNTYPED_DEFAULT] = bp; } - if (c == '\n') - unterminated_string(s_lineno, s_line, s_cptr); - if (c == '\\') + if (bp->destructor != NULL) + destructor_redeclared_warning(a_lineno, a_line, a_cptr); + else + /* replace "$$" with "(*val)" in destructor code */ + bp->destructor = process_destructor_XX(code_text, NULL); + } + else if (cptr[1] == '*' && cptr[2] == '>') + { /* "no per-symbol or per-type" default destructor */ + cptr += 3; + if ((bp = default_destructor[TYPED_DEFAULT]) == NULL) { - c = *cptr++; - putc(c, f); - if (c == '\n') - { - get_line(); - if (line == 0) - unterminated_string(s_lineno, s_line, s_cptr); - } + static char typed_default[] = "<*>"; + bp = make_bucket("typed default"); + bp->tag = typed_default; + default_destructor[TYPED_DEFAULT] = bp; + } + if (bp->destructor != NULL) + destructor_redeclared_warning(a_lineno, a_line, a_cptr); + else + { + /* postpone re-processing destructor $$s until end of grammar spec */ + bp->destructor = TMALLOC(char, strlen(code_text) + 1); + NO_SPACE(bp->destructor); + strcpy(bp->destructor, code_text); } } + else + { /* "semantic type" default destructor */ + tag = get_tag(); + bp = lookup_type_destructor(tag); + if (bp->destructor != NULL) + destructor_redeclared_warning(a_lineno, a_line, a_cptr); + else + /* replace "$$" with "(*val).tag" in destructor code */ + bp->destructor = process_destructor_XX(code_text, tag); + } } + else if (isalpha(c) || c == '_' || c == '.' || c == '$') + { /* "symbol" destructor */ + bp = get_name(); + if (bp->destructor != NULL) + destructor_redeclared_warning(a_lineno, a_line, a_cptr); + else + { + /* postpone re-processing destructor $$s until end of grammar spec */ + bp->destructor = TMALLOC(char, strlen(code_text) + 1); + NO_SPACE(bp->destructor); + strcpy(bp->destructor, code_text); + } + } + else + break; + } + free(a_line); + free(code_text); +} - case '/': - c = *cptr; - if (c == '/') +static char * +process_destructor_XX(char *code, char *tag) +{ + int c; + int quote; + int depth; + struct mstring *new_code = msnew(); + char *codeptr = code; + + depth = 0; + loop: /* step thru code */ + c = *codeptr; + if (c == '$' && codeptr[1] == '$') + { + codeptr += 2; + if (tag == NULL) + msprintf(new_code, "(*val)"); + else + msprintf(new_code, "(*val).%s", tag); + goto loop; + } + if (isalpha(c) || c == '_' || c == '$') + { + do { - putc('*', f); - while ((c = *++cptr) != '\n') + mputc(new_code, c); + c = *++codeptr; + } + while (isalnum(c) || c == '_' || c == '$'); + goto loop; + } + ++codeptr; + mputc(new_code, c); + switch (c) + { + case L_CURL: + ++depth; + goto loop; + + case R_CURL: + if (--depth > 0) + goto loop; + return msdone(new_code); + + case '\'': + case '"': + quote = c; + for (;;) + { + c = *codeptr++; + mputc(new_code, c); + if (c == quote) + goto loop; + if (c == '\\') { - if (c == '*' && cptr[1] == '/') - fprintf(f, "* "); - else - putc(c, f); + c = *codeptr++; + mputc(new_code, c); } - fprintf(f, "*/\n"); - goto next_line; } + + case '/': + c = *codeptr; if (c == '*') { - int c_lineno = lineno; - char *c_line = dup_line(); - char *c_cptr = c_line + (cptr - line - 1); - - putc('*', f); - ++cptr; + mputc(new_code, c); + ++codeptr; for (;;) { - c = *cptr++; - putc(c, f); - if (c == '*' && *cptr == '/') + c = *codeptr++; + mputc(new_code, c); + if (c == '*' && *codeptr == '/') { - putc('/', f); - ++cptr; - FREE(c_line); + mputc(new_code, '/'); + ++codeptr; goto loop; } - if (c == '\n') - { - get_line(); - if (line == 0) - unterminated_comment(c_lineno, c_line, c_cptr); - } } } goto loop; @@ -1775,6 +2673,7 @@ copy_action(void) goto loop; } } +#endif /* defined(YYBTYACC) */ static int mark_symbol(void) @@ -1808,7 +2707,6 @@ mark_symbol(void) else { syntax_error(lineno, line, cptr); - /*NOTREACHED */ } if (rprec[nrules] != UNDEFINED && bp->prec != rprec[nrules]) @@ -1839,7 +2737,11 @@ read_grammar(void) || c == '\'' || c == '"') add_symbol(); +#if defined(YYBTYACC) + else if (c == L_CURL || c == '=' || (backtrack && c == L_BRAC)) +#else else if (c == L_CURL || c == '=') +#endif copy_action(); else if (c == '|') { @@ -1856,6 +2758,10 @@ read_grammar(void) syntax_error(lineno, line, cptr); } end_rule(); +#if defined(YYBTYACC) + if (goal->args > 0) + start_requires_args(goal->name); +#endif } static void @@ -1959,6 +2865,9 @@ pack_symbols(void) bucket *bp; bucket **v; Value_t i, j, k, n; +#if defined(YYBTYACC) + Value_t max_tok_pval; +#endif nsyms = 2; ntokens = 1; @@ -1969,7 +2878,7 @@ pack_symbols(void) ++ntokens; } start_symbol = (Value_t) ntokens; - nvars = nsyms - ntokens; + nvars = (Value_t) (nsyms - ntokens); symbol_name = TMALLOC(char *, nsyms); NO_SPACE(symbol_name); @@ -1977,12 +2886,26 @@ pack_symbols(void) symbol_value = TMALLOC(Value_t, nsyms); NO_SPACE(symbol_value); - symbol_prec = TMALLOC(short, nsyms); + symbol_prec = TMALLOC(Value_t, nsyms); NO_SPACE(symbol_prec); symbol_assoc = TMALLOC(char, nsyms); NO_SPACE(symbol_assoc); +#if defined(YYBTYACC) + symbol_pval = TMALLOC(Value_t, nsyms); + NO_SPACE(symbol_pval); + + if (destructor) + { + symbol_destructor = CALLOC(sizeof(char *), nsyms); + NO_SPACE(symbol_destructor); + + symbol_type_tag = CALLOC(sizeof(char *), nsyms); + NO_SPACE(symbol_type_tag); + } +#endif + v = TMALLOC(bucket *, nsyms); NO_SPACE(v); @@ -2061,17 +2984,34 @@ pack_symbols(void) symbol_value[0] = 0; symbol_prec[0] = 0; symbol_assoc[0] = TOKEN; +#if defined(YYBTYACC) + symbol_pval[0] = 0; + max_tok_pval = 0; +#endif for (i = 1; i < ntokens; ++i) { symbol_name[i] = v[i]->name; symbol_value[i] = v[i]->value; symbol_prec[i] = v[i]->prec; symbol_assoc[i] = v[i]->assoc; +#if defined(YYBTYACC) + symbol_pval[i] = v[i]->value; + if (symbol_pval[i] > max_tok_pval) + max_tok_pval = symbol_pval[i]; + if (destructor) + { + symbol_destructor[i] = v[i]->destructor; + symbol_type_tag[i] = v[i]->tag; + } +#endif } symbol_name[start_symbol] = name_pool; symbol_value[start_symbol] = -1; symbol_prec[start_symbol] = 0; symbol_assoc[start_symbol] = TOKEN; +#if defined(YYBTYACC) + symbol_pval[start_symbol] = (Value_t) (max_tok_pval + 1); +#endif for (++i; i < nsyms; ++i) { k = v[i]->index; @@ -2079,6 +3019,14 @@ pack_symbols(void) symbol_value[k] = v[i]->value; symbol_prec[k] = v[i]->prec; symbol_assoc[k] = v[i]->assoc; +#if defined(YYBTYACC) + symbol_pval[k] = (Value_t) ((max_tok_pval + 1) + v[i]->value + 1); + if (destructor) + { + symbol_destructor[k] = v[i]->destructor; + symbol_type_tag[k] = v[i]->tag; + } +#endif } if (gflag) @@ -2130,6 +3078,21 @@ pack_grammar(void) j = 4; for (i = 3; i < nrules; ++i) { +#if defined(YYBTYACC) + if (plhs[i]->args > 0) + { + if (plhs[i]->argnames) + { + FREE(plhs[i]->argnames); + plhs[i]->argnames = NULL; + } + if (plhs[i]->argtags) + { + FREE(plhs[i]->argtags); + plhs[i]->argtags = NULL; + } + } +#endif /* defined(YYBTYACC) */ rlhs[i] = plhs[i]->index; rrhs[i] = j; assoc = TOKEN; @@ -2156,6 +3119,9 @@ pack_grammar(void) FREE(plhs); FREE(pitem); +#if defined(YYBTYACC) + clean_arg_cache(); +#endif } static void @@ -2197,6 +3163,85 @@ print_grammar(void) } } +#if defined(YYBTYACC) +static void +finalize_destructors(void) +{ + int i; + bucket *bp; + char *tag; + + for (i = 2; i < nsyms; ++i) + { + tag = symbol_type_tag[i]; + if (symbol_destructor[i] == NULL) + { + if (tag == NULL) + { /* use <> destructor, if there is one */ + if ((bp = default_destructor[UNTYPED_DEFAULT]) != NULL) + { + symbol_destructor[i] = TMALLOC(char, + strlen(bp->destructor) + 1); + NO_SPACE(symbol_destructor[i]); + strcpy(symbol_destructor[i], bp->destructor); + } + } + else + { /* use type destructor for this tag, if there is one */ + bp = lookup_type_destructor(tag); + if (bp->destructor != NULL) + { + symbol_destructor[i] = TMALLOC(char, + strlen(bp->destructor) + 1); + NO_SPACE(symbol_destructor[i]); + strcpy(symbol_destructor[i], bp->destructor); + } + else + { /* use <*> destructor, if there is one */ + if ((bp = default_destructor[TYPED_DEFAULT]) != NULL) + /* replace "$$" with "(*val).tag" in destructor code */ + symbol_destructor[i] + = process_destructor_XX(bp->destructor, tag); + } + } + } + else + { /* replace "$$" with "(*val)[.tag]" in destructor code */ + symbol_destructor[i] + = process_destructor_XX(symbol_destructor[i], tag); + } + } + /* 'symbol_type_tag[]' elements are freed by 'free_tags()' */ + DO_FREE(symbol_type_tag); /* no longer needed */ + if ((bp = default_destructor[UNTYPED_DEFAULT]) != NULL) + { + FREE(bp->name); + /* 'bp->tag' is a static value, don't free */ + FREE(bp->destructor); + FREE(bp); + } + if ((bp = default_destructor[TYPED_DEFAULT]) != NULL) + { + FREE(bp->name); + /* 'bp->tag' is a static value, don't free */ + FREE(bp->destructor); + FREE(bp); + } + if ((bp = default_destructor[TYPE_SPECIFIED]) != NULL) + { + bucket *p; + for (; bp; bp = p) + { + p = bp->link; + FREE(bp->name); + /* 'bp->tag' freed by 'free_tags()' */ + FREE(bp->destructor); + FREE(bp); + } + } +} +#endif /* defined(YYBTYACC) */ + void reader(void) { @@ -2205,13 +3250,17 @@ reader(void) read_declarations(); read_grammar(); free_symbol_table(); - free_tags(); pack_names(); check_symbols(); pack_symbols(); pack_grammar(); free_symbols(); print_grammar(); +#if defined(YYBTYACC) + if (destructor) + finalize_destructors(); +#endif + free_tags(); } #ifdef NO_LEAKS @@ -2248,5 +3297,10 @@ reader_leaks(void) DO_FREE(symbol_prec); DO_FREE(symbol_assoc); DO_FREE(symbol_value); +#if defined(YYBTYACC) + DO_FREE(symbol_pval); + DO_FREE(symbol_destructor); + DO_FREE(symbol_type_tag); +#endif } #endif diff --git a/contrib/byacc/skel2c b/contrib/byacc/skel2c new file mode 100644 index 000000000..d6f9f5909 --- /dev/null +++ b/contrib/byacc/skel2c @@ -0,0 +1,112 @@ +# vile: awkmode +function noident(given) { + gsub(/\$/,"@", given); + return given; +} +BEGIN { havesection = 0; + version = "$Id: skel2c,v 1.3 2014/04/06 19:48:04 tom Exp $"; + nsec = 0; + ifdef = ""; + printf "/* This file generated automatically using\n * %s\n */\n\n", + noident(version); + } +/[$]Id[:][^$]*[$]/ { + printf "%s\n", noident($0); + next; + } +/^%% *insert *VERSION *here/ { + printf " CONCAT1(\"#define YYMAJOR \", YYMAJOR),\n"; + printf " CONCAT1(\"#define YYMINOR \", YYMINOR),\n"; + printf "#ifdef YYPATCH\n"; + printf " CONCAT1(\"#define YYPATCH \", YYPATCH),\n"; + printf "#endif\n"; + next; + } +/^%%ifdef/ { + if (NF >= 2) { + printf "#if defined(%s)\n", $2; + printf " \"#if %s\",\n", $2; + } else { + _abort_exit = 1; + printf "skel2c: ill-formed %%ifdef in skeleton file on line %d\n", FNR > "/dev/stderr"; + exit 2; + } + if (ifdef != "") { + printf "skel2c: nested %%ifdef in skeleton file on line %d\n", FNR > "/dev/stderr"; + exit 2; + } + ifdef = $2; + next; + } +/^%%endif/ { + if (ifdef != "") { + if (NF >= 2) { + printf " \"#endif /* %s */\",\n", $2; + printf "#endif /* defined(%s) */\n", $2; + } else { + printf " \"#endif /* %s */\",\n", ifdef; + printf "#endif /* defined(%s) */\n", ifdef; + } + ifdef = ""; + } else { + printf " \"#endif\",\n"; + printf "#endif\n"; + printf "skel2c: unmatched %endif in skeleton file on line %d\n", FNR > "/dev/stderr"; + exit 2; + } + next; + } +/^%%/ { if (havesection) { + printf " 0\n};\n\n"; + } + if (NF >= 2) { + havesection = 1; + section = $2; + seclist[nsec] = section; + nsec = nsec + 1; + printf "const char *const %s[] =\n{\n", $2; + } else { + havesection = 0; + } + next; + } + { if (havesection) { + # Could use 'gsub(/\\/, "\\\\")' instead of the following + # two lines, but there's a bug in mawk and the original + # awk (not in gawk) which is triggered by that. + gsub(/\\/, "\\\1"); + gsub(/\1/, "\\"); +# gsub(/\t/, "\\t"); # change '\t' to "\\t" + gsub(/\"/, "\\\""); + printf " \"%s\",\n", $0; + } else { + print $0; + } + } +END { if (_abort_exit) + exit 2; + if (havesection) { + print " 0\n};\n"; + } + if (nsec > 0) { + print "void"; + print "write_section(FILE * fp, const char *const section[])"; + print "{"; + print " int i;"; + print " const char *s;\n"; + print " for (i = 0; (s = section[i]) != 0; ++i)"; + print " {"; + print "\tif (fp == code_file)"; + print "\t ++outline;"; + print "\tfprintf(fp, \"%s\\n\", s);"; + print " }"; + print "}"; + } else { + print "skel2c: no sections defined in skeleton file" > "/dev/stderr"; + exit 2; + } + if (ifdef != "") { + printf "skel2c: unmatched %%ifdef %s at end of skeleton file\n", $ifdef > "/dev/stderr"; + exit 2; + } + } diff --git a/contrib/byacc/symtab.c b/contrib/byacc/symtab.c index 983918093..e7f6fade0 100644 --- a/contrib/byacc/symtab.c +++ b/contrib/byacc/symtab.c @@ -1,4 +1,4 @@ -/* $Id: symtab.c,v 1.10 2012/05/26 15:16:12 tom Exp $ */ +/* $Id: symtab.c,v 1.11 2014/03/26 00:17:09 Tom.Shields Exp $ */ #include "defs.h" @@ -48,6 +48,12 @@ make_bucket(const char *name) bp->prec = 0; bp->class = UNKNOWN; bp->assoc = TOKEN; +#if defined(YYBTYACC) + bp->args = -1; + bp->argnames = 0; + bp->argtags = 0; + bp->destructor = 0; +#endif strcpy(bp->name, name); return (bp); diff --git a/contrib/byacc/test/code_error.tab.h b/contrib/byacc/test/btyacc/big_b.error similarity index 100% rename from contrib/byacc/test/code_error.tab.h rename to contrib/byacc/test/btyacc/big_b.error diff --git a/contrib/byacc/test/btyacc/big_b.output b/contrib/byacc/test/btyacc/big_b.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/btyacc/big_b.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/error.tab.h b/contrib/byacc/test/btyacc/big_l.error similarity index 100% rename from contrib/byacc/test/error.tab.h rename to contrib/byacc/test/btyacc/big_l.error diff --git a/contrib/byacc/test/btyacc/big_l.output b/contrib/byacc/test/btyacc/big_l.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/btyacc/big_l.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/btyacc/btyacc_calc1.error b/contrib/byacc/test/btyacc/btyacc_calc1.error new file mode 100644 index 000000000..1807ff988 --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_calc1.error @@ -0,0 +1 @@ +YACC: 17 shift/reduce conflicts, 27 reduce/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/btyacc_calc1.output b/contrib/byacc/test/btyacc/btyacc_calc1.output new file mode 100644 index 000000000..fe68c4378 --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_calc1.output @@ -0,0 +1,949 @@ + 0 $accept : lines $end + + 1 lines : + 2 | lines line '\n' + 3 | lines error '\n' + + 4 line : dexp + 5 | vexp + 6 | DREG '=' dexp + 7 | VREG '=' vexp + + 8 dexp : CONST + 9 | DREG + 10 | dexp '+' dexp + 11 | dexp '-' dexp + 12 | dexp '*' dexp + 13 | dexp '/' dexp + 14 | '-' dexp + 15 | '(' dexp ')' + + 16 vexp : dexp + 17 | '(' dexp ',' dexp ')' + 18 | VREG + 19 | vexp '+' vexp + 20 | dexp '+' vexp + 21 | vexp '-' vexp + 22 | dexp '-' vexp + 23 | vexp '*' vexp + 24 | dexp '*' vexp + 25 | vexp '/' vexp + 26 | dexp '/' vexp + 27 | '-' vexp + 28 | '(' vexp ')' + +state 0 + $accept : . lines $end (0) + lines : . (1) + + . reduce 1 + + lines goto 1 + + +state 1 + $accept : lines . $end (0) + lines : lines . line '\n' (2) + lines : lines . error '\n' (3) + + $end accept + error shift 2 + DREG shift 3 + VREG shift 4 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 8 + vexp goto 9 + line goto 10 + + +state 2 + lines : lines error . '\n' (3) + + '\n' shift 11 + . error + + +state 3 + line : DREG . '=' dexp (6) + dexp : DREG . (9) + + '=' shift 12 + '+' reduce 9 + '-' reduce 9 + '*' reduce 9 + '/' reduce 9 + '\n' reduce 9 + + +state 4 + line : VREG . '=' vexp (7) + vexp : VREG . (18) + + '=' shift 13 + '+' reduce 18 + '-' reduce 18 + '*' reduce 18 + '/' reduce 18 + '\n' reduce 18 + + +state 5 + dexp : CONST . (8) + + . reduce 8 + + +state 6 + dexp : '-' . dexp (14) + vexp : '-' . vexp (27) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 16 + vexp goto 17 + + +state 7 + dexp : '(' . dexp ')' (15) + vexp : '(' . dexp ',' dexp ')' (17) + vexp : '(' . vexp ')' (28) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 18 + vexp goto 19 + + +8: shift/reduce conflict (shift 20, reduce 16) on '+' +8: shift/reduce conflict (shift 21, reduce 16) on '-' +8: shift/reduce conflict (shift 22, reduce 16) on '*' +8: shift/reduce conflict (shift 23, reduce 16) on '/' +8: reduce/reduce conflict (reduce 4, reduce 16) on '\n' +state 8 + line : dexp . (4) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' [trial] shift 20 + '-' [trial] shift 21 + '*' [trial] shift 22 + '/' [trial] shift 23 + '+' [trial] reduce 16 + '-' [trial] reduce 16 + '*' [trial] reduce 16 + '/' [trial] reduce 16 + '\n' [trial] reduce 4 + '\n' [trial] reduce 16 + + +state 9 + line : vexp . (5) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' reduce 5 + + +state 10 + lines : lines line . '\n' (2) + + '\n' shift 28 + . error + + +state 11 + lines : lines error '\n' . (3) + + . reduce 3 + + +state 12 + line : DREG '=' . dexp (6) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 31 + + +state 13 + line : VREG '=' . vexp (7) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 32 + vexp goto 33 + + +state 14 + dexp : DREG . (9) + + . reduce 9 + + +state 15 + vexp : VREG . (18) + + . reduce 18 + + +16: reduce/reduce conflict (reduce 14, reduce 16) on '+' +16: reduce/reduce conflict (reduce 14, reduce 16) on '-' +16: reduce/reduce conflict (reduce 14, reduce 16) on '*' +16: reduce/reduce conflict (reduce 14, reduce 16) on '/' +16: reduce/reduce conflict (reduce 14, reduce 16) on '\n' +16: reduce/reduce conflict (reduce 14, reduce 16) on ')' +state 16 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' [trial] reduce 14 + '+' [trial] reduce 16 + '-' [trial] reduce 14 + '-' [trial] reduce 16 + '*' [trial] reduce 14 + '*' [trial] reduce 16 + '/' [trial] reduce 14 + '/' [trial] reduce 16 + '\n' [trial] reduce 14 + '\n' [trial] reduce 16 + ')' [trial] reduce 14 + ')' [trial] reduce 16 + ',' reduce 14 + + +state 17 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '-' vexp . (27) + + . reduce 27 + + +18: shift/reduce conflict (shift 20, reduce 16) on '+' +18: shift/reduce conflict (shift 21, reduce 16) on '-' +18: shift/reduce conflict (shift 22, reduce 16) on '*' +18: shift/reduce conflict (shift 23, reduce 16) on '/' +18: shift/reduce conflict (shift 34, reduce 16) on ')' +state 18 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + vexp : dexp . (16) + vexp : '(' dexp . ',' dexp ')' (17) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' [trial] shift 20 + '-' [trial] shift 21 + '*' [trial] shift 22 + '/' [trial] shift 23 + ')' [trial] shift 34 + ',' shift 35 + '+' [trial] reduce 16 + '-' [trial] reduce 16 + '*' [trial] reduce 16 + '/' [trial] reduce 16 + ')' [trial] reduce 16 + + +state 19 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '(' vexp . ')' (28) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + ')' shift 36 + . error + + +state 20 + dexp : dexp '+' . dexp (10) + vexp : dexp '+' . vexp (20) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 37 + vexp goto 38 + + +state 21 + dexp : dexp '-' . dexp (11) + vexp : dexp '-' . vexp (22) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 39 + vexp goto 40 + + +state 22 + dexp : dexp '*' . dexp (12) + vexp : dexp '*' . vexp (24) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 41 + vexp goto 42 + + +state 23 + dexp : dexp '/' . dexp (13) + vexp : dexp '/' . vexp (26) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 43 + vexp goto 44 + + +state 24 + vexp : vexp '+' . vexp (19) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 32 + vexp goto 45 + + +state 25 + vexp : vexp '-' . vexp (21) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 32 + vexp goto 46 + + +state 26 + vexp : vexp '*' . vexp (23) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 32 + vexp goto 47 + + +state 27 + vexp : vexp '/' . vexp (25) + + DREG shift 14 + VREG shift 15 + CONST shift 5 + '-' shift 6 + '(' shift 7 + . error + + dexp goto 32 + vexp goto 48 + + +state 28 + lines : lines line '\n' . (2) + + . reduce 2 + + +state 29 + dexp : '-' . dexp (14) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 49 + + +state 30 + dexp : '(' . dexp ')' (15) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 50 + + +state 31 + line : DREG '=' dexp . (6) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + '\n' reduce 6 + + +32: shift/reduce conflict (shift 20, reduce 16) on '+' +32: shift/reduce conflict (shift 21, reduce 16) on '-' +32: shift/reduce conflict (shift 22, reduce 16) on '*' +32: shift/reduce conflict (shift 23, reduce 16) on '/' +state 32 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' [trial] shift 20 + '-' [trial] shift 21 + '*' [trial] shift 22 + '/' [trial] shift 23 + '+' [trial] reduce 16 + '-' [trial] reduce 16 + '*' [trial] reduce 16 + '/' [trial] reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 33 + line : VREG '=' vexp . (7) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' reduce 7 + + +state 34 + dexp : '(' dexp ')' . (15) + + . reduce 15 + + +state 35 + vexp : '(' dexp ',' . dexp ')' (17) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 55 + + +state 36 + vexp : '(' vexp ')' . (28) + + . reduce 28 + + +37: reduce/reduce conflict (reduce 10, reduce 16) on '+' +37: reduce/reduce conflict (reduce 10, reduce 16) on '-' +37: shift/reduce conflict (shift 22, reduce 16) on '*' +37: shift/reduce conflict (shift 23, reduce 16) on '/' +37: reduce/reduce conflict (reduce 10, reduce 16) on '\n' +37: reduce/reduce conflict (reduce 10, reduce 16) on ')' +state 37 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' [trial] shift 22 + '/' [trial] shift 23 + '+' [trial] reduce 10 + '+' [trial] reduce 16 + '-' [trial] reduce 10 + '-' [trial] reduce 16 + '*' [trial] reduce 16 + '/' [trial] reduce 16 + '\n' [trial] reduce 10 + '\n' [trial] reduce 16 + ')' [trial] reduce 10 + ')' [trial] reduce 16 + ',' reduce 10 + + +state 38 + vexp : vexp . '+' vexp (19) + vexp : dexp '+' vexp . (20) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 20 + '-' reduce 20 + '\n' reduce 20 + ')' reduce 20 + + +39: reduce/reduce conflict (reduce 11, reduce 16) on '+' +39: reduce/reduce conflict (reduce 11, reduce 16) on '-' +39: shift/reduce conflict (shift 22, reduce 16) on '*' +39: shift/reduce conflict (shift 23, reduce 16) on '/' +39: reduce/reduce conflict (reduce 11, reduce 16) on '\n' +39: reduce/reduce conflict (reduce 11, reduce 16) on ')' +state 39 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' [trial] shift 22 + '/' [trial] shift 23 + '+' [trial] reduce 11 + '+' [trial] reduce 16 + '-' [trial] reduce 11 + '-' [trial] reduce 16 + '*' [trial] reduce 16 + '/' [trial] reduce 16 + '\n' [trial] reduce 11 + '\n' [trial] reduce 16 + ')' [trial] reduce 11 + ')' [trial] reduce 16 + ',' reduce 11 + + +state 40 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : dexp '-' vexp . (22) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 22 + '-' reduce 22 + '\n' reduce 22 + ')' reduce 22 + + +41: reduce/reduce conflict (reduce 12, reduce 16) on '+' +41: reduce/reduce conflict (reduce 12, reduce 16) on '-' +41: reduce/reduce conflict (reduce 12, reduce 16) on '*' +41: reduce/reduce conflict (reduce 12, reduce 16) on '/' +41: reduce/reduce conflict (reduce 12, reduce 16) on '\n' +41: reduce/reduce conflict (reduce 12, reduce 16) on ')' +state 41 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' [trial] reduce 12 + '+' [trial] reduce 16 + '-' [trial] reduce 12 + '-' [trial] reduce 16 + '*' [trial] reduce 12 + '*' [trial] reduce 16 + '/' [trial] reduce 12 + '/' [trial] reduce 16 + '\n' [trial] reduce 12 + '\n' [trial] reduce 16 + ')' [trial] reduce 12 + ')' [trial] reduce 16 + ',' reduce 12 + + +state 42 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : dexp '*' vexp . (24) + vexp : vexp . '/' vexp (25) + + . reduce 24 + + +43: reduce/reduce conflict (reduce 13, reduce 16) on '+' +43: reduce/reduce conflict (reduce 13, reduce 16) on '-' +43: reduce/reduce conflict (reduce 13, reduce 16) on '*' +43: reduce/reduce conflict (reduce 13, reduce 16) on '/' +43: reduce/reduce conflict (reduce 13, reduce 16) on '\n' +43: reduce/reduce conflict (reduce 13, reduce 16) on ')' +state 43 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' [trial] reduce 13 + '+' [trial] reduce 16 + '-' [trial] reduce 13 + '-' [trial] reduce 16 + '*' [trial] reduce 13 + '*' [trial] reduce 16 + '/' [trial] reduce 13 + '/' [trial] reduce 16 + '\n' [trial] reduce 13 + '\n' [trial] reduce 16 + ')' [trial] reduce 13 + ')' [trial] reduce 16 + ',' reduce 13 + + +state 44 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : dexp '/' vexp . (26) + + . reduce 26 + + +state 45 + vexp : vexp . '+' vexp (19) + vexp : vexp '+' vexp . (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 19 + '-' reduce 19 + '\n' reduce 19 + ')' reduce 19 + + +state 46 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp '-' vexp . (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 21 + '-' reduce 21 + '\n' reduce 21 + ')' reduce 21 + + +state 47 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp '*' vexp . (23) + vexp : vexp . '/' vexp (25) + + . reduce 23 + + +state 48 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : vexp '/' vexp . (25) + + . reduce 25 + + +state 49 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + + . reduce 14 + + +state 50 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 34 + . error + + +state 51 + dexp : dexp '+' . dexp (10) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 56 + + +state 52 + dexp : dexp '-' . dexp (11) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 57 + + +state 53 + dexp : dexp '*' . dexp (12) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 58 + + +state 54 + dexp : dexp '/' . dexp (13) + + DREG shift 14 + CONST shift 5 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 59 + + +state 55 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : '(' dexp ',' dexp . ')' (17) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 60 + . error + + +state 56 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 10 + '-' reduce 10 + '\n' reduce 10 + ')' reduce 10 + + +state 57 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 11 + '-' reduce 11 + '\n' reduce 11 + ')' reduce 11 + + +state 58 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + + . reduce 12 + + +state 59 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + + . reduce 13 + + +state 60 + vexp : '(' dexp ',' dexp ')' . (17) + + . reduce 17 + + +State 8 contains 4 shift/reduce conflicts, 1 reduce/reduce conflict. +State 16 contains 6 reduce/reduce conflicts. +State 18 contains 5 shift/reduce conflicts. +State 32 contains 4 shift/reduce conflicts. +State 37 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 39 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 41 contains 6 reduce/reduce conflicts. +State 43 contains 6 reduce/reduce conflicts. + + +15 terminals, 5 nonterminals +29 grammar rules, 61 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DREG + 3 258 VREG + 4 259 CONST + 5 43 '+' + 6 45 '-' + 7 42 '*' + 8 47 '/' + 9 260 UMINUS + 10 10 '\n' + 11 61 '=' + 12 40 '(' + 13 41 ')' + 14 44 ',' + 15 261 $accept + 16 262 lines + 17 263 dexp + 18 264 vexp + 19 265 line diff --git a/contrib/byacc/test/btyacc/btyacc_calc1.tab.c b/contrib/byacc/test/btyacc/btyacc_calc1.tab.c new file mode 100644 index 000000000..6e4cadecc --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_calc1.tab.c @@ -0,0 +1,1732 @@ +/* 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 1 +#define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") + +#ifndef yyparse +#define yyparse calc1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc1_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc1_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc1_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc1_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc1_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc1_" + +#define YYPURE 1 + +#line 3 "btyacc_calc1.y" + +/* http://dinosaur.compilertools.net/yacc/index.html */ + +#include +#include +#include +#include + +typedef struct interval +{ + double lo, hi; +} +INTERVAL; + +INTERVAL vmul(double, double, INTERVAL); +INTERVAL vdiv(double, double, INTERVAL); + +int dcheck(INTERVAL); + +double dreg[26]; +INTERVAL vreg[26]; + +#line 29 "btyacc_calc1.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 158 "btyacc_calc1.tab.c" + +/* 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 +# ifdef YYLEX_PARAM_TYPE +# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) +# else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) +# endif +# define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(YYSTYPE *yylval) +# define YYLEX yylex(&yylval) +#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 DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT calc1_lhs[] = { -1, + 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, +}; +static const YYINT calc1_len[] = { 2, + 0, 3, 3, 1, 1, 3, 3, 1, 1, 3, + 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 3, +}; +static const YYINT calc1_defred[] = { 1, + 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, + 3, 0, 0, 9, 18, 0, 27, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, + 0, 24, 0, 26, 0, 0, 23, 25, 14, 0, + 0, 0, 0, 0, 0, 0, 0, 12, 13, 17, +}; +static const YYINT calc1_stos[] = { 0, + 262, 256, 257, 258, 259, 45, 40, 263, 264, 265, + 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, + 45, 42, 47, 43, 45, 42, 47, 10, 45, 40, + 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, + 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, + 43, 45, 42, 47, 263, 263, 263, 263, 263, 41, +}; +static const YYINT calc1_dgoto[] = { 1, + 32, 9, 10, +}; +static const YYINT calc1_sindex[] = { 0, + -40, -9, -59, -54, 0, -37, -37, 0, 82, 4, + 0, -34, -37, 0, 0, 0, 0, -31, -25, -37, + -37, -37, -37, -37, -37, -37, -37, 0, -34, -34, + 132, 0, 82, 0, -34, 0, 0, -12, 0, -12, + 0, 0, 0, 0, -12, -12, 0, 0, 0, 112, + -34, -34, -34, -34, 119, -11, -11, 0, 0, 0, +}; +static const YYINT calc1_rindex[] = { 0, + 0, 0, 51, 58, 0, 0, 0, 0, 11, 0, + 0, 0, 0, 0, 0, -16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 19, 9, 27, 0, 0, 0, -5, 41, -4, 77, + -2, 0, 8, 0, 78, 85, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 92, 99, 0, 0, 0, +}; +#if YYBTYACC +static const YYINT calc1_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 126, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 138, 0, 0, 0, 0, 17, 0, 24, 0, + 31, 0, 38, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +#endif +static const YYINT calc1_gindex[] = { 0, + 3, 125, 0, +}; +#define YYTABLESIZE 225 +static const YYINT calc1_table[] = { 7, + 11, 12, 7, 8, 6, 30, 13, 6, 16, 18, + 29, 14, 35, 28, 31, 36, 26, 24, 16, 25, + 5, 27, 37, 39, 41, 43, 20, 14, 6, 26, + 53, 49, 50, 23, 27, 54, 7, 55, 10, 11, + 26, 12, 14, 14, 14, 0, 14, 29, 14, 16, + 20, 13, 0, 56, 57, 58, 59, 20, 6, 20, + 9, 20, 0, 9, 23, 6, 23, 18, 23, 0, + 9, 26, 26, 26, 11, 26, 0, 26, 29, 29, + 29, 20, 29, 20, 29, 20, 22, 19, 0, 0, + 0, 0, 9, 9, 21, 9, 0, 9, 0, 18, + 18, 10, 18, 0, 18, 0, 6, 0, 11, 3, + 0, 9, 0, 0, 0, 0, 0, 22, 19, 22, + 19, 22, 19, 26, 24, 21, 25, 21, 27, 21, + 17, 19, 10, 0, 10, 0, 10, 33, 0, 11, + 0, 11, 0, 11, 38, 40, 42, 44, 45, 46, + 47, 48, 34, 53, 51, 0, 52, 0, 54, 60, + 53, 51, 0, 52, 0, 54, 18, 6, 0, 0, + 3, 0, 9, 53, 51, 0, 52, 0, 54, 6, + 0, 0, 3, 0, 9, 0, 0, 0, 0, 0, + 0, 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, 5, 14, + 15, 5, 14, 0, 5, +}; +static const YYINT calc1_check[] = { 40, + 10, 61, 40, 1, 45, 40, 61, 45, 6, 7, + 45, 10, 44, 10, 12, 41, 42, 43, 10, 45, + 10, 47, 20, 21, 22, 23, 10, 44, 10, 42, + 42, 29, 30, 10, 47, 47, 10, 35, 44, 44, + 10, 44, 41, 42, 43, -1, 45, 10, 47, 41, + 10, 44, -1, 51, 52, 53, 54, 41, 42, 43, + 10, 45, -1, 47, 41, 42, 43, 10, 45, -1, + 47, 41, 42, 43, 10, 45, -1, 47, 41, 42, + 43, 41, 45, 43, 47, 45, 10, 10, -1, -1, + -1, -1, 42, 43, 10, 45, -1, 47, -1, 42, + 43, 10, 45, -1, 47, -1, 42, 43, 10, 45, + -1, 47, -1, -1, -1, -1, -1, 41, 41, 43, + 43, 45, 45, 42, 43, 41, 45, 43, 47, 45, + 6, 7, 41, -1, 43, -1, 45, 13, -1, 41, + -1, 43, -1, 45, 20, 21, 22, 23, 24, 25, + 26, 27, 41, 42, 43, -1, 45, -1, 47, 41, + 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, + 45, -1, 47, 42, 43, -1, 45, -1, 47, 42, + 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, + -1, -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, 259, 257, + 258, 259, 257, -1, 259, +}; +#if YYBTYACC +static const YYINT calc1_ctable[] = { 20, + 16, -1, 21, 16, -1, 22, 16, -1, 23, 16, + -1, 4, 16, -1, 14, 16, -1, 34, 16, -1, + 10, 16, -1, 11, 16, -1, 12, 16, -1, 13, + 16, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 260 +#define YYUNDFTOKEN 266 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc1_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,0,0, +"error","DREG","VREG","CONST","UMINUS","$accept","lines","dexp","vexp","line", +"illegal-symbol", +}; +static const char *const calc1_rule[] = { +"$accept : lines", +"lines :", +"lines : lines line '\\n'", +"lines : lines error '\\n'", +"line : dexp", +"line : vexp", +"line : DREG '=' dexp", +"line : VREG '=' vexp", +"dexp : CONST", +"dexp : DREG", +"dexp : dexp '+' dexp", +"dexp : dexp '-' dexp", +"dexp : dexp '*' dexp", +"dexp : dexp '/' dexp", +"dexp : '-' dexp", +"dexp : '(' dexp ')'", +"vexp : dexp", +"vexp : '(' dexp ',' dexp ')'", +"vexp : VREG", +"vexp : vexp '+' vexp", +"vexp : dexp '+' vexp", +"vexp : vexp '-' vexp", +"vexp : dexp '-' vexp", +"vexp : vexp '*' vexp", +"vexp : dexp '*' vexp", +"vexp : vexp '/' vexp", +"vexp : dexp '/' vexp", +"vexp : '-' vexp", +"vexp : '(' vexp ')'", + +}; +#endif + +int yydebug; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 */ +#line 174 "btyacc_calc1.y" + /* beginning of subroutines section */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +#define BSZ 50 /* buffer size for floating point numbers */ + +static void +YYERROR_DECL() +{ + fprintf(stderr, "%s\n", s); +} + + /* lexical analysis */ + +static int +YYLEX_DECL() +{ + int c; + + while ((c = getchar()) == ' ') + { /* skip over blanks */ + } + + if (isupper(c)) + { +#if YYPURE + (*yylval).ival = c - 'A'; +#else + yylval.ival = c - 'A'; +#endif + return (VREG); + } + if (islower(c)) + { +#if YYPURE + (*yylval).ival = c - 'a'; +#else + yylval.ival = c - 'a'; +#endif + return (DREG); + } + + if (isdigit(c) || c == '.') + { + /* gobble up digits, points, exponents */ + char buf[BSZ + 1], *cp = buf; + int dot = 0, expr = 0; + + for (; (cp - buf) < BSZ; ++cp, c = getchar()) + { + + *cp = (char) c; + if (isdigit(c)) + continue; + if (c == '.') + { + if (dot++ || expr) + return ('.'); /* will cause syntax error */ + continue; + } + + if (c == 'e') + { + if (expr++) + return ('e'); /* will cause syntax error */ + continue; + } + + /* end of number */ + break; + } + *cp = '\0'; + + if ((cp - buf) >= BSZ) + printf("constant too long: truncated\n"); + else + ungetc(c, stdin); /* push back last char read */ +#if YYPURE + (*yylval).dval = atof(buf); +#else + yylval.dval = atof(buf); +#endif + return (CONST); + } + return (c); +} + +static INTERVAL +hilo(double a, double b, double c, double d) +{ + /* returns the smallest interval containing a, b, c, and d */ + /* used by *, / routines */ + INTERVAL v; + + if (a > b) + { + v.hi = a; + v.lo = b; + } + else + { + v.hi = b; + v.lo = a; + } + + if (c > d) + { + if (c > v.hi) + v.hi = c; + if (d < v.lo) + v.lo = d; + } + else + { + if (d > v.hi) + v.hi = d; + if (c < v.lo) + v.lo = c; + } + return (v); +} + +INTERVAL +vmul(double a, double b, INTERVAL v) +{ + return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); +} + +int +dcheck(INTERVAL v) +{ + if (v.hi >= 0. && v.lo <= 0.) + { + printf("divisor interval contains 0.\n"); + return (1); + } + return (0); +} + +INTERVAL +vdiv(double a, double b, INTERVAL v) +{ + return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); +} +#line 598 "btyacc_calc1.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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 yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* variables for the parser stack */ + 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 short *yylexp = 0; + + static short *yylexemes = 0; +#endif /* YYBTYACC */ + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 2: +#line 51 "btyacc_calc1.y" +{YYVALID;} +break; +case 3: +#line 52 "btyacc_calc1.y" +{YYVALID;} if (!yytrial) +#line 53 "btyacc_calc1.y" +{ + yyerrok; + } +break; +case 4: + if (!yytrial) +#line 59 "btyacc_calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[0].dval); + } +break; +case 5: + if (!yytrial) +#line 63 "btyacc_calc1.y" + { + (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[0].vval.lo, yystack.l_mark[0].vval.hi); + } +break; +case 6: + if (!yytrial) +#line 67 "btyacc_calc1.y" + { + dreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].dval; + } +break; +case 7: + if (!yytrial) +#line 71 "btyacc_calc1.y" + { + vreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].vval; + } +break; +case 9: + if (!yytrial) +#line 78 "btyacc_calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; + } +break; +case 10: + if (!yytrial) +#line 82 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +break; +case 11: + if (!yytrial) +#line 86 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +break; +case 12: + if (!yytrial) +#line 90 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +break; +case 13: + if (!yytrial) +#line 94 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +break; +case 14: + if (!yytrial) +#line 98 "btyacc_calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +break; +case 15: + if (!yytrial) +#line 102 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +break; +case 16: + if (!yytrial) +#line 108 "btyacc_calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +break; +case 17: + if (!yytrial) +#line 112 "btyacc_calc1.y" + { + yyval.vval.lo = yystack.l_mark[-3].dval; + yyval.vval.hi = yystack.l_mark[-1].dval; + if ( yyval.vval.lo > yyval.vval.hi ) + { + (void) printf("interval out of order\n"); + YYERROR; + } + } +break; +case 18: + if (!yytrial) +#line 122 "btyacc_calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +break; +case 19: + if (!yytrial) +#line 126 "btyacc_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; + } +break; +case 20: + if (!yytrial) +#line 131 "btyacc_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; + } +break; +case 21: + if (!yytrial) +#line 136 "btyacc_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; + } +break; +case 22: + if (!yytrial) +#line 141 "btyacc_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; + } +break; +case 23: + if (!yytrial) +#line 146 "btyacc_calc1.y" + { + yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 24: + if (!yytrial) +#line 150 "btyacc_calc1.y" + { + yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 25: + if (!yytrial) +#line 154 "btyacc_calc1.y" + { + if (dcheck(yystack.l_mark[0].vval)) YYERROR; + yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 26: + if (!yytrial) +#line 159 "btyacc_calc1.y" + { + if (dcheck ( yystack.l_mark[0].vval )) YYERROR; + yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 27: + if (!yytrial) +#line 164 "btyacc_calc1.y" + { + yyval.vval.hi = -yystack.l_mark[0].vval.lo; + yyval.vval.lo = -yystack.l_mark[0].vval.hi; + } +break; +case 28: + if (!yytrial) +#line 169 "btyacc_calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +break; +#line 1498 "btyacc_calc1.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/btyacc_calc1.tab.h b/contrib/byacc/test/btyacc/btyacc_calc1.tab.h new file mode 100644 index 000000000..1802350b0 --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_calc1.tab.h @@ -0,0 +1,23 @@ +#ifndef _calc1__defines_h_ +#define _calc1__defines_h_ + +#define DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE calc1_lval; + +#endif /* _calc1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/btyacc_demo.error b/contrib/byacc/test/btyacc/btyacc_demo.error new file mode 100644 index 000000000..4542fbf3b --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_demo.error @@ -0,0 +1 @@ +YACC: 7 shift/reduce conflicts, 5 reduce/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/btyacc_demo.output b/contrib/byacc/test/btyacc/btyacc_demo.output new file mode 100644 index 000000000..bc64d2467 --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_demo.output @@ -0,0 +1,1360 @@ + 0 $accept : input $end + + 1 opt_scope : + 2 | CLCL + 3 | opt_scope ID CLCL + + 4 typename : opt_scope ID + + 5 $$1 : + + 6 input : $$1 decl_list + + 7 decl_list : + + 8 $$2 : + + 9 decl_list : decl_list $$2 decl + + 10 $$3 : + + 11 decl : decl_specs $$2 $$3 declarator_list ';' + + 12 $$4 : + + 13 decl : decl_specs $$2 $$3 declarator $$4 block_statement + + 14 decl_specs : decl_spec + 15 | decl_specs $$2 decl_spec + + 16 cv_quals : + 17 | cv_quals cv_qual + + 18 decl_spec : cv_qual + 19 | typename + 20 | EXTERN + 21 | REGISTER + 22 | STATIC + + 23 cv_qual : CONST + 24 | VOLATILE + + 25 $$5 : + + 26 $$6 : + + 27 declarator_list : declarator_list ',' $$5 $$6 declarator + 28 | declarator + + 29 declarator : + 30 | ID + + 31 $$7 : + + 32 $$8 : + + 33 declarator : '(' $$7 $$8 declarator ')' + 34 | '*' cv_quals $$5 $$6 declarator + 35 | declarator '[' $$5 expr ']' + 36 | declarator '(' $$5 formal_arg_list ')' cv_quals + + 37 formal_arg_list : + 38 | nonempty_formal_arg_list + + 39 nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$7 formal_arg + 40 | formal_arg + + 41 formal_arg : decl_specs $$2 $$3 declarator + + 42 expr : expr '+' $$7 expr + 43 | expr '-' $$7 expr + 44 | expr '*' $$7 expr + 45 | expr '%' $$7 expr + 46 | expr '/' $$7 expr + 47 | '*' $$2 expr + 48 | ID + 49 | CONSTANT + + 50 statement : decl + + 51 $$9 : + + 52 statement : $$9 expr ';' + + 53 $$10 : + + 54 $$11 : + + 55 statement : IF '(' $$7 expr ')' THEN $$10 statement ELSE $$11 statement + 56 | IF '(' $$7 expr ')' THEN $$10 statement + + 57 $$12 : + + 58 statement : $$12 block_statement + + 59 statement_list : + 60 | statement_list $$2 statement + + 61 block_statement : '{' $$2 statement_list '}' + +state 0 + $accept : . input $end (0) + $$1 : . (5) + + . reduce 5 + + input goto 1 + $$1 goto 2 + + +state 1 + $accept : input . $end (0) + + $end accept + + +state 2 + input : $$1 . decl_list (6) + decl_list : . (7) + + . reduce 7 + + decl_list goto 3 + + +state 3 + input : $$1 decl_list . (6) + decl_list : decl_list . $$2 decl (9) + $$2 : . (8) + + $end reduce 6 + ID reduce 8 + EXTERN reduce 8 + REGISTER reduce 8 + STATIC reduce 8 + CONST reduce 8 + VOLATILE reduce 8 + CLCL reduce 8 + + $$2 goto 4 + + +state 4 + decl_list : decl_list $$2 . decl (9) + opt_scope : . (1) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + CLCL shift 10 + ID reduce 1 + + decl goto 11 + decl_specs goto 12 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + + +state 5 + decl_spec : EXTERN . (20) + + . reduce 20 + + +state 6 + decl_spec : REGISTER . (21) + + . reduce 21 + + +state 7 + decl_spec : STATIC . (22) + + . reduce 22 + + +state 8 + cv_qual : CONST . (23) + + . reduce 23 + + +state 9 + cv_qual : VOLATILE . (24) + + . reduce 24 + + +state 10 + opt_scope : CLCL . (2) + + . reduce 2 + + +state 11 + decl_list : decl_list $$2 decl . (9) + + . reduce 9 + + +state 12 + decl : decl_specs . $$2 $$3 declarator_list ';' (11) + decl : decl_specs . $$2 $$3 declarator $$4 block_statement (13) + decl_specs : decl_specs . $$2 decl_spec (15) + $$2 : . (8) + + . reduce 8 + + $$2 goto 17 + + +state 13 + decl_specs : decl_spec . (14) + + . reduce 14 + + +state 14 + decl_spec : typename . (19) + + . reduce 19 + + +state 15 + decl_spec : cv_qual . (18) + + . reduce 18 + + +state 16 + opt_scope : opt_scope . ID CLCL (3) + typename : opt_scope . ID (4) + + ID shift 18 + . error + + +17: reduce/reduce conflict (reduce 1, reduce 10) on ID +state 17 + decl : decl_specs $$2 . $$3 declarator_list ';' (11) + decl : decl_specs $$2 . $$3 declarator $$4 block_statement (13) + decl_specs : decl_specs $$2 . decl_spec (15) + opt_scope : . (1) + $$3 : . (10) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + CLCL shift 10 + '*' reduce 10 + '(' reduce 10 + '[' reduce 10 + ID [trial] reduce 1 + ID [trial] reduce 10 + ';' reduce 10 + ',' reduce 10 + '{' reduce 10 + + decl_spec goto 19 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$3 goto 20 + + +18: shift/reduce conflict (shift 21, reduce 4) on CLCL +state 18 + opt_scope : opt_scope ID . CLCL (3) + typename : opt_scope ID . (4) + + CLCL [trial] shift 21 + '*' reduce 4 + '(' reduce 4 + '[' reduce 4 + ID reduce 4 + EXTERN reduce 4 + REGISTER reduce 4 + STATIC reduce 4 + CONST reduce 4 + VOLATILE reduce 4 + CLCL [trial] reduce 4 + ';' reduce 4 + ',' reduce 4 + ')' reduce 4 + '{' reduce 4 + + +state 19 + decl_specs : decl_specs $$2 decl_spec . (15) + + . reduce 15 + + +20: shift/reduce conflict (shift 23, reduce 29) on '(' +state 20 + decl : decl_specs $$2 $$3 . declarator_list ';' (11) + decl : decl_specs $$2 $$3 . declarator $$4 block_statement (13) + declarator : . (29) + + '*' shift 22 + '(' [trial] shift 23 + ID shift 24 + '(' [trial] reduce 29 + '[' reduce 29 + ';' reduce 29 + ',' reduce 29 + '{' reduce 29 + + declarator_list goto 25 + declarator goto 26 + + +state 21 + opt_scope : opt_scope ID CLCL . (3) + + . reduce 3 + + +state 22 + declarator : '*' . cv_quals $$5 $$6 declarator (34) + cv_quals : . (16) + + . reduce 16 + + cv_quals goto 27 + + +state 23 + declarator : '(' . $$7 $$8 declarator ')' (33) + $$7 : . (31) + + . reduce 31 + + $$7 goto 28 + + +state 24 + declarator : ID . (30) + + . reduce 30 + + +state 25 + decl : decl_specs $$2 $$3 declarator_list . ';' (11) + declarator_list : declarator_list . ',' $$5 $$6 declarator (27) + + ';' shift 29 + ',' shift 30 + . error + + +state 26 + decl : decl_specs $$2 $$3 declarator . $$4 block_statement (13) + declarator_list : declarator . (28) + declarator : declarator . '[' $$5 expr ']' (35) + declarator : declarator . '(' $$5 formal_arg_list ')' cv_quals (36) + $$4 : . (12) + + '(' shift 31 + '[' shift 32 + ';' reduce 28 + ',' reduce 28 + '{' reduce 12 + + $$4 goto 33 + + +state 27 + cv_quals : cv_quals . cv_qual (17) + declarator : '*' cv_quals . $$5 $$6 declarator (34) + $$5 : . (25) + + CONST shift 8 + VOLATILE shift 9 + '*' reduce 25 + '(' reduce 25 + '[' reduce 25 + ID reduce 25 + ';' reduce 25 + ',' reduce 25 + ')' reduce 25 + '{' reduce 25 + + cv_qual goto 34 + $$5 goto 35 + + +state 28 + declarator : '(' $$7 . $$8 declarator ')' (33) + $$8 : . (32) + + . reduce 32 + + $$8 goto 36 + + +state 29 + decl : decl_specs $$2 $$3 declarator_list ';' . (11) + + . reduce 11 + + +state 30 + declarator_list : declarator_list ',' . $$5 $$6 declarator (27) + $$5 : . (25) + + . reduce 25 + + $$5 goto 37 + + +state 31 + declarator : declarator '(' . $$5 formal_arg_list ')' cv_quals (36) + $$5 : . (25) + + . reduce 25 + + $$5 goto 38 + + +state 32 + declarator : declarator '[' . $$5 expr ']' (35) + $$5 : . (25) + + . reduce 25 + + $$5 goto 39 + + +state 33 + decl : decl_specs $$2 $$3 declarator $$4 . block_statement (13) + + '{' shift 40 + . error + + block_statement goto 41 + + +state 34 + cv_quals : cv_quals cv_qual . (17) + + . reduce 17 + + +state 35 + declarator : '*' cv_quals $$5 . $$6 declarator (34) + $$6 : . (26) + + . reduce 26 + + $$6 goto 42 + + +36: shift/reduce conflict (shift 23, reduce 29) on '(' +state 36 + declarator : '(' $$7 $$8 . declarator ')' (33) + declarator : . (29) + + '*' shift 22 + '(' [trial] shift 23 + ID shift 24 + '(' [trial] reduce 29 + '[' reduce 29 + ')' reduce 29 + + declarator goto 43 + + +state 37 + declarator_list : declarator_list ',' $$5 . $$6 declarator (27) + $$6 : . (26) + + . reduce 26 + + $$6 goto 44 + + +state 38 + declarator : declarator '(' $$5 . formal_arg_list ')' cv_quals (36) + opt_scope : . (1) + formal_arg_list : . (37) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + CLCL shift 10 + ID reduce 1 + ')' reduce 37 + + formal_arg goto 45 + decl_specs goto 46 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + formal_arg_list goto 47 + nonempty_formal_arg_list goto 48 + + +state 39 + declarator : declarator '[' $$5 . expr ']' (35) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 52 + + +state 40 + block_statement : '{' . $$2 statement_list '}' (61) + $$2 : . (8) + + . reduce 8 + + $$2 goto 53 + + +state 41 + decl : decl_specs $$2 $$3 declarator $$4 block_statement . (13) + + . reduce 13 + + +42: shift/reduce conflict (shift 23, reduce 29) on '(' +state 42 + declarator : '*' cv_quals $$5 $$6 . declarator (34) + declarator : . (29) + + '*' shift 22 + '(' [trial] shift 23 + ID shift 24 + '(' [trial] reduce 29 + '[' reduce 29 + ';' reduce 29 + ',' reduce 29 + ')' reduce 29 + '{' reduce 29 + + declarator goto 54 + + +state 43 + declarator : '(' $$7 $$8 declarator . ')' (33) + declarator : declarator . '[' $$5 expr ']' (35) + declarator : declarator . '(' $$5 formal_arg_list ')' cv_quals (36) + + '(' shift 31 + '[' shift 32 + ')' shift 55 + . error + + +44: shift/reduce conflict (shift 23, reduce 29) on '(' +state 44 + declarator_list : declarator_list ',' $$5 $$6 . declarator (27) + declarator : . (29) + + '*' shift 22 + '(' [trial] shift 23 + ID shift 24 + '(' [trial] reduce 29 + '[' reduce 29 + ';' reduce 29 + ',' reduce 29 + + declarator goto 56 + + +state 45 + nonempty_formal_arg_list : formal_arg . (40) + + . reduce 40 + + +state 46 + decl_specs : decl_specs . $$2 decl_spec (15) + formal_arg : decl_specs . $$2 $$3 declarator (41) + $$2 : . (8) + + . reduce 8 + + $$2 goto 57 + + +state 47 + declarator : declarator '(' $$5 formal_arg_list . ')' cv_quals (36) + + ')' shift 58 + . error + + +state 48 + formal_arg_list : nonempty_formal_arg_list . (38) + nonempty_formal_arg_list : nonempty_formal_arg_list . ',' $$7 formal_arg (39) + + ',' shift 59 + ')' reduce 38 + + +state 49 + expr : '*' . $$2 expr (47) + $$2 : . (8) + + . reduce 8 + + $$2 goto 60 + + +state 50 + expr : ID . (48) + + . reduce 48 + + +state 51 + expr : CONSTANT . (49) + + . reduce 49 + + +state 52 + declarator : declarator '[' $$5 expr . ']' (35) + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + + '+' shift 61 + '-' shift 62 + '*' shift 63 + '/' shift 64 + '%' shift 65 + ']' shift 66 + . error + + +state 53 + block_statement : '{' $$2 . statement_list '}' (61) + statement_list : . (59) + + . reduce 59 + + statement_list goto 67 + + +state 54 + declarator : '*' cv_quals $$5 $$6 declarator . (34) + declarator : declarator . '[' $$5 expr ']' (35) + declarator : declarator . '(' $$5 formal_arg_list ')' cv_quals (36) + + '(' shift 31 + '[' shift 32 + ';' reduce 34 + ',' reduce 34 + ')' reduce 34 + '{' reduce 34 + + +state 55 + declarator : '(' $$7 $$8 declarator ')' . (33) + + . reduce 33 + + +state 56 + declarator_list : declarator_list ',' $$5 $$6 declarator . (27) + declarator : declarator . '[' $$5 expr ']' (35) + declarator : declarator . '(' $$5 formal_arg_list ')' cv_quals (36) + + '(' shift 31 + '[' shift 32 + ';' reduce 27 + ',' reduce 27 + + +57: reduce/reduce conflict (reduce 1, reduce 10) on ID +state 57 + decl_specs : decl_specs $$2 . decl_spec (15) + formal_arg : decl_specs $$2 . $$3 declarator (41) + opt_scope : . (1) + $$3 : . (10) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + CLCL shift 10 + '*' reduce 10 + '(' reduce 10 + '[' reduce 10 + ID [trial] reduce 1 + ID [trial] reduce 10 + ',' reduce 10 + ')' reduce 10 + + decl_spec goto 19 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$3 goto 68 + + +state 58 + declarator : declarator '(' $$5 formal_arg_list ')' . cv_quals (36) + cv_quals : . (16) + + . reduce 16 + + cv_quals goto 69 + + +state 59 + nonempty_formal_arg_list : nonempty_formal_arg_list ',' . $$7 formal_arg (39) + $$7 : . (31) + + . reduce 31 + + $$7 goto 70 + + +state 60 + expr : '*' $$2 . expr (47) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 71 + + +state 61 + expr : expr '+' . $$7 expr (42) + $$7 : . (31) + + . reduce 31 + + $$7 goto 72 + + +state 62 + expr : expr '-' . $$7 expr (43) + $$7 : . (31) + + . reduce 31 + + $$7 goto 73 + + +state 63 + expr : expr '*' . $$7 expr (44) + $$7 : . (31) + + . reduce 31 + + $$7 goto 74 + + +state 64 + expr : expr '/' . $$7 expr (46) + $$7 : . (31) + + . reduce 31 + + $$7 goto 75 + + +state 65 + expr : expr '%' . $$7 expr (45) + $$7 : . (31) + + . reduce 31 + + $$7 goto 76 + + +state 66 + declarator : declarator '[' $$5 expr ']' . (35) + + . reduce 35 + + +state 67 + statement_list : statement_list . $$2 statement (60) + block_statement : '{' $$2 statement_list . '}' (61) + $$2 : . (8) + + '}' shift 77 + '*' reduce 8 + ID reduce 8 + CONSTANT reduce 8 + EXTERN reduce 8 + REGISTER reduce 8 + STATIC reduce 8 + CONST reduce 8 + VOLATILE reduce 8 + IF reduce 8 + CLCL reduce 8 + '{' reduce 8 + + $$2 goto 78 + + +68: shift/reduce conflict (shift 23, reduce 29) on '(' +state 68 + formal_arg : decl_specs $$2 $$3 . declarator (41) + declarator : . (29) + + '*' shift 22 + '(' [trial] shift 23 + ID shift 24 + '(' [trial] reduce 29 + '[' reduce 29 + ',' reduce 29 + ')' reduce 29 + + declarator goto 79 + + +state 69 + cv_quals : cv_quals . cv_qual (17) + declarator : declarator '(' $$5 formal_arg_list ')' cv_quals . (36) + + CONST shift 8 + VOLATILE shift 9 + '(' reduce 36 + '[' reduce 36 + ';' reduce 36 + ',' reduce 36 + ')' reduce 36 + '{' reduce 36 + + cv_qual goto 34 + + +state 70 + nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$7 . formal_arg (39) + opt_scope : . (1) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + CLCL shift 10 + ID reduce 1 + + formal_arg goto 80 + decl_specs goto 46 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + + +state 71 + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + expr : '*' $$2 expr . (47) + + . reduce 47 + + +state 72 + expr : expr '+' $$7 . expr (42) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 81 + + +state 73 + expr : expr '-' $$7 . expr (43) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 82 + + +state 74 + expr : expr '*' $$7 . expr (44) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 83 + + +state 75 + expr : expr '/' $$7 . expr (46) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 84 + + +state 76 + expr : expr '%' $$7 . expr (45) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 85 + + +state 77 + block_statement : '{' $$2 statement_list '}' . (61) + + . reduce 61 + + +78: reduce/reduce conflict (reduce 1, reduce 51) on ID +state 78 + statement_list : statement_list $$2 . statement (60) + opt_scope : . (1) + $$9 : . (51) + $$12 : . (57) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + IF shift 86 + CLCL shift 10 + '*' reduce 51 + ID [trial] reduce 1 + ID [trial] reduce 51 + CONSTANT reduce 51 + '{' reduce 57 + + decl goto 87 + statement goto 88 + decl_specs goto 12 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$9 goto 89 + $$12 goto 90 + + +state 79 + declarator : declarator . '[' $$5 expr ']' (35) + declarator : declarator . '(' $$5 formal_arg_list ')' cv_quals (36) + formal_arg : decl_specs $$2 $$3 declarator . (41) + + '(' shift 31 + '[' shift 32 + ',' reduce 41 + ')' reduce 41 + + +state 80 + nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$7 formal_arg . (39) + + . reduce 39 + + +state 81 + expr : expr . '+' $$7 expr (42) + expr : expr '+' $$7 expr . (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + + '*' shift 63 + '/' shift 64 + '%' shift 65 + '+' reduce 42 + '-' reduce 42 + ';' reduce 42 + ')' reduce 42 + ']' reduce 42 + + +state 82 + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr '-' $$7 expr . (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + + '*' shift 63 + '/' shift 64 + '%' shift 65 + '+' reduce 43 + '-' reduce 43 + ';' reduce 43 + ')' reduce 43 + ']' reduce 43 + + +state 83 + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr '*' $$7 expr . (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + + . reduce 44 + + +state 84 + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + expr : expr '/' $$7 expr . (46) + + . reduce 46 + + +state 85 + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr '%' $$7 expr . (45) + expr : expr . '/' $$7 expr (46) + + . reduce 45 + + +state 86 + statement : IF . '(' $$7 expr ')' THEN $$10 statement ELSE $$11 statement (55) + statement : IF . '(' $$7 expr ')' THEN $$10 statement (56) + + '(' shift 91 + . error + + +state 87 + statement : decl . (50) + + . reduce 50 + + +state 88 + statement_list : statement_list $$2 statement . (60) + + . reduce 60 + + +state 89 + statement : $$9 . expr ';' (52) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 92 + + +state 90 + statement : $$12 . block_statement (58) + + '{' shift 40 + . error + + block_statement goto 93 + + +state 91 + statement : IF '(' . $$7 expr ')' THEN $$10 statement ELSE $$11 statement (55) + statement : IF '(' . $$7 expr ')' THEN $$10 statement (56) + $$7 : . (31) + + . reduce 31 + + $$7 goto 94 + + +state 92 + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + statement : $$9 expr . ';' (52) + + '+' shift 61 + '-' shift 62 + '*' shift 63 + '/' shift 64 + '%' shift 65 + ';' shift 95 + . error + + +state 93 + statement : $$12 block_statement . (58) + + . reduce 58 + + +state 94 + statement : IF '(' $$7 . expr ')' THEN $$10 statement ELSE $$11 statement (55) + statement : IF '(' $$7 . expr ')' THEN $$10 statement (56) + + '*' shift 49 + ID shift 50 + CONSTANT shift 51 + . error + + expr goto 96 + + +state 95 + statement : $$9 expr ';' . (52) + + . reduce 52 + + +state 96 + expr : expr . '+' $$7 expr (42) + expr : expr . '-' $$7 expr (43) + expr : expr . '*' $$7 expr (44) + expr : expr . '%' $$7 expr (45) + expr : expr . '/' $$7 expr (46) + statement : IF '(' $$7 expr . ')' THEN $$10 statement ELSE $$11 statement (55) + statement : IF '(' $$7 expr . ')' THEN $$10 statement (56) + + '+' shift 61 + '-' shift 62 + '*' shift 63 + '/' shift 64 + '%' shift 65 + ')' shift 97 + . error + + +state 97 + statement : IF '(' $$7 expr ')' . THEN $$10 statement ELSE $$11 statement (55) + statement : IF '(' $$7 expr ')' . THEN $$10 statement (56) + + THEN shift 98 + . error + + +state 98 + statement : IF '(' $$7 expr ')' THEN . $$10 statement ELSE $$11 statement (55) + statement : IF '(' $$7 expr ')' THEN . $$10 statement (56) + $$10 : . (53) + + . reduce 53 + + $$10 goto 99 + + +99: reduce/reduce conflict (reduce 1, reduce 51) on ID +state 99 + statement : IF '(' $$7 expr ')' THEN $$10 . statement ELSE $$11 statement (55) + statement : IF '(' $$7 expr ')' THEN $$10 . statement (56) + opt_scope : . (1) + $$9 : . (51) + $$12 : . (57) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + IF shift 86 + CLCL shift 10 + '*' reduce 51 + ID [trial] reduce 1 + ID [trial] reduce 51 + CONSTANT reduce 51 + '{' reduce 57 + + decl goto 87 + statement goto 100 + decl_specs goto 12 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$9 goto 89 + $$12 goto 90 + + +100: shift/reduce conflict (shift 101, reduce 56) on ELSE +state 100 + statement : IF '(' $$7 expr ')' THEN $$10 statement . ELSE $$11 statement (55) + statement : IF '(' $$7 expr ')' THEN $$10 statement . (56) + + ELSE [trial] shift 101 + '*' reduce 56 + ID reduce 56 + CONSTANT reduce 56 + EXTERN reduce 56 + REGISTER reduce 56 + STATIC reduce 56 + CONST reduce 56 + VOLATILE reduce 56 + IF reduce 56 + ELSE [trial] reduce 56 + CLCL reduce 56 + '{' reduce 56 + '}' reduce 56 + + +state 101 + statement : IF '(' $$7 expr ')' THEN $$10 statement ELSE . $$11 statement (55) + $$11 : . (54) + + . reduce 54 + + $$11 goto 102 + + +102: reduce/reduce conflict (reduce 1, reduce 51) on ID +state 102 + statement : IF '(' $$7 expr ')' THEN $$10 statement ELSE $$11 . statement (55) + opt_scope : . (1) + $$9 : . (51) + $$12 : . (57) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + IF shift 86 + CLCL shift 10 + '*' reduce 51 + ID [trial] reduce 1 + ID [trial] reduce 51 + CONSTANT reduce 51 + '{' reduce 57 + + decl goto 87 + statement goto 103 + decl_specs goto 12 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$9 goto 89 + $$12 goto 90 + + +state 103 + statement : IF '(' $$7 expr ')' THEN $$10 statement ELSE $$11 statement . (55) + + . reduce 55 + + +State 17 contains 1 reduce/reduce conflict. +State 18 contains 1 shift/reduce conflict. +State 20 contains 1 shift/reduce conflict. +State 36 contains 1 shift/reduce conflict. +State 42 contains 1 shift/reduce conflict. +State 44 contains 1 shift/reduce conflict. +State 57 contains 1 reduce/reduce conflict. +State 68 contains 1 shift/reduce conflict. +State 78 contains 1 reduce/reduce conflict. +State 99 contains 1 reduce/reduce conflict. +State 100 contains 1 shift/reduce conflict. +State 102 contains 1 reduce/reduce conflict. + + +29 terminals, 31 nonterminals +62 grammar rules, 104 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 43 '+' + 3 45 '-' + 4 42 '*' + 5 47 '/' + 6 37 '%' + 7 257 PREFIX + 8 258 POSTFIX + 9 40 '(' + 10 91 '[' + 11 46 '.' + 12 259 ID + 13 260 CONSTANT + 14 261 EXTERN + 15 262 REGISTER + 16 263 STATIC + 17 264 CONST + 18 265 VOLATILE + 19 266 IF + 20 267 THEN + 21 268 ELSE + 22 269 CLCL + 23 59 ';' + 24 44 ',' + 25 41 ')' + 26 93 ']' + 27 123 '{' + 28 125 '}' + 29 270 $accept + 30 271 input + 31 272 expr + 32 273 decl + 33 274 declarator_list + 34 275 decl_list + 35 276 statement + 36 277 statement_list + 37 278 block_statement + 38 279 declarator + 39 280 formal_arg + 40 281 decl_specs + 41 282 decl_spec + 42 283 typename + 43 284 cv_quals + 44 285 cv_qual + 45 286 opt_scope + 46 287 formal_arg_list + 47 288 nonempty_formal_arg_list + 48 289 $$1 + 49 290 $$2 + 50 291 $$3 + 51 292 $$4 + 52 293 $$5 + 53 294 $$6 + 54 295 $$7 + 55 296 $$8 + 56 297 $$9 + 57 298 $$10 + 58 299 $$11 + 59 300 $$12 diff --git a/contrib/byacc/test/btyacc/btyacc_demo.tab.c b/contrib/byacc/test/btyacc/btyacc_demo.tab.c new file mode 100644 index 000000000..4a92347b6 --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_demo.tab.c @@ -0,0 +1,2331 @@ +/* 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 1 +#define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") + +#ifndef yyparse +#define yyparse demo_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex demo_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror demo_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar demo_char +#endif /* yychar */ + +#ifndef yyval +#define yyval demo_val +#endif /* yyval */ + +#ifndef yylval +#define yylval demo_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug demo_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs demo_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag demo_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs demo_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen demo_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred demo_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos demo_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto demo_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex demo_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex demo_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex demo_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable demo_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck demo_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname demo_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule demo_rule +#endif /* yyrule */ + +#ifndef yyloc +#define yyloc demo_loc +#endif /* yyloc */ + +#ifndef yylloc +#define yylloc demo_lloc +#endif /* yylloc */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex demo_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable demo_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "demo_" + +#define YYPURE 0 + +#line 15 "btyacc_demo.y" +/* dummy types just for compile check */ +typedef int Code; +typedef int Decl_List; +typedef int Expr; +typedef int Expr_List; +typedef int Scope; +typedef int Type; +enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF }; + +typedef unsigned char bool; +typedef struct Decl { + Scope *scope; + Type *type; + bool (*istype)(void); +} Decl; + +#include "btyacc_demo.tab.h" +#include +#include +#line 36 "btyacc_demo.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union { + Scope *scope; + Expr *expr; + Expr_List *elist; + Type *type; + Decl *decl; + Decl_List *dlist; + Code *code; + char *id; + } YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 167 "btyacc_demo.tab.c" + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +/* Default: YYLTYPE is the text position type. */ +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +#define YYLTYPE_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(YYLTYPE loc, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(yylloc, msg) +#endif + +#ifndef YYDESTRUCT_DECL +#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc) +#endif +#ifndef YYDESTRUCT_CALL +#define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc) +#endif + +extern int YYPARSE_DECL(); + +#define PREFIX 257 +#define POSTFIX 258 +#define ID 259 +#define CONSTANT 260 +#define EXTERN 261 +#define REGISTER 262 +#define STATIC 263 +#define CONST 264 +#define VOLATILE 265 +#define IF 266 +#define THEN 267 +#define ELSE 268 +#define CLCL 269 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT demo_lhs[] = { -1, + 15, 15, 15, 12, 18, 0, 4, 19, 4, 20, + 2, 21, 2, 10, 10, 13, 13, 11, 11, 11, + 11, 11, 14, 14, 22, 23, 3, 3, 8, 8, + 24, 25, 8, 8, 8, 8, 16, 16, 17, 17, + 9, 1, 1, 1, 1, 1, 1, 1, 1, 5, + 26, 5, 27, 28, 5, 5, 29, 5, 6, 6, + 7, +}; +static const YYINT demo_len[] = { 2, + 0, 1, 3, 2, 0, 2, 0, 0, 3, 0, + 5, 0, 6, 1, 3, 0, 2, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 5, 1, 0, 1, + 0, 0, 5, 5, 5, 6, 0, 1, 4, 1, + 4, 4, 4, 4, 4, 4, 3, 1, 1, 1, + 0, 3, 0, 0, 11, 8, 0, 2, 0, 3, + 4, +}; +static const YYINT demo_defred[] = { 5, + 0, 7, 0, 0, 20, 21, 22, 23, 24, 2, + 9, 8, 14, 19, 18, 0, 0, 0, 15, 0, + 3, 16, 31, 30, 0, 0, 0, 32, 11, 25, + 25, 25, 0, 17, 26, 0, 26, 0, 0, 8, + 13, 0, 0, 0, 40, 8, 0, 0, 8, 48, + 49, 0, 59, 0, 33, 0, 0, 16, 31, 0, + 31, 31, 31, 31, 31, 35, 0, 0, 0, 0, + 47, 0, 0, 0, 0, 0, 61, 0, 0, 39, + 0, 0, 44, 46, 45, 0, 50, 60, 0, 0, + 31, 0, 58, 0, 52, 0, 0, 53, 0, 0, + 54, 0, 55, +}; +static const YYINT demo_stos[] = { 0, + 271, 289, 275, 290, 261, 262, 263, 264, 265, 269, + 273, 281, 282, 283, 285, 286, 290, 259, 282, 291, + 269, 42, 40, 259, 274, 279, 284, 295, 59, 44, + 40, 91, 292, 285, 293, 296, 293, 293, 293, 123, + 278, 294, 279, 294, 280, 281, 287, 288, 42, 259, + 260, 272, 290, 279, 41, 279, 290, 41, 44, 290, + 43, 45, 42, 47, 37, 93, 277, 291, 284, 295, + 272, 295, 295, 295, 295, 295, 125, 290, 279, 280, + 272, 272, 272, 272, 272, 266, 273, 276, 297, 300, + 40, 272, 278, 295, 59, 272, 41, 267, 298, 276, + 268, 299, 276, +}; +static const YYINT demo_dgoto[] = { 1, + 52, 87, 25, 3, 88, 67, 41, 26, 45, 12, + 13, 14, 27, 15, 16, 47, 48, 2, 4, 20, + 33, 35, 42, 28, 36, 89, 99, 102, 90, +}; +static const YYINT demo_sindex[] = { 0, + 0, 0, 0, -124, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -256, -124, 0, 0, -33, + 0, 0, 0, 0, 34, -4, -205, 0, 0, 0, + 0, 0, -110, 0, 0, -33, 0, -124, -15, 0, + 0, -33, -36, -33, 0, 0, 4, 7, 0, 0, + 0, 5, 0, -4, 0, -4, -124, 0, 0, -15, + 0, 0, 0, 0, 0, 0, -46, -33, -205, -124, + 0, -15, -15, -15, -15, -15, 0, -91, -4, 0, + 122, 122, 0, 0, 0, 40, 0, 0, -15, -110, + 0, 106, 0, -15, 0, 113, -183, 0, -91, 0, + 0, -91, 0, +}; +static const YYINT demo_rindex[] = { 0, + 0, 0, 1, -157, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -28, -22, 0, -29, + 0, 0, 0, 0, 0, -27, -34, 0, 0, 0, + 0, 0, 0, 0, 0, 8, 0, -12, 0, 0, + 0, -20, 0, 32, 0, 0, 0, 69, 0, 0, + 0, 0, 0, -18, 0, 56, 33, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -31, -1, -6, -157, + 0, 0, 0, 0, 0, 0, 0, -14, 63, 0, + 13, 23, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -14, -42, + 0, -14, 0, +}; +#if YYBTYACC +static const YYINT demo_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -145, -150, 0, 81, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, + 0, 91, 0, 112, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -113, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -98, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -96, -92, + 0, -82, 0, +}; +#endif +static const YYINT demo_gindex[] = { 0, + 53, 175, 0, 0, 9, 0, 90, 76, 111, 27, + 29, 0, 124, -25, 0, 0, 0, 0, 21, 126, + 0, 136, 147, 71, 0, 0, 0, 0, 0, +}; +#define YYTABLESIZE 270 +static const YYINT demo_table[] = { 56, + 6, 34, 18, 31, 55, 25, 25, 25, 22, 25, + 8, 10, 40, 10, 29, 10, 28, 4, 4, 4, + 29, 4, 34, 29, 25, 34, 49, 51, 37, 29, + 10, 28, 17, 36, 36, 31, 4, 36, 29, 29, + 34, 65, 29, 34, 58, 19, 63, 61, 29, 62, + 59, 64, 36, 42, 32, 42, 25, 42, 8, 9, + 53, 29, 10, 43, 46, 43, 57, 43, 4, 60, + 29, 42, 10, 10, 10, 29, 10, 30, 77, 91, + 56, 43, 56, 98, 36, 19, 32, 78, 25, 29, + 29, 8, 29, 29, 10, 12, 46, 66, 29, 27, + 4, 1, 29, 41, 34, 42, 41, 100, 57, 38, + 103, 43, 71, 0, 27, 43, 36, 54, 4, 56, + 7, 7, 29, 10, 81, 82, 83, 84, 85, 70, + 7, 72, 73, 74, 75, 76, 5, 6, 7, 8, + 9, 92, 65, 79, 10, 0, 96, 63, 61, 65, + 62, 7, 64, 97, 63, 61, 7, 62, 65, 64, + 9, 94, 9, 63, 95, 37, 38, 39, 64, 5, + 6, 7, 8, 9, 86, 13, 9, 10, 11, 93, + 80, 69, 68, 44, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 56, 56, 56, 56, + 56, 56, 56, 56, 25, 24, 56, 8, 8, 8, + 8, 8, 8, 8, 8, 0, 4, 8, 4, 4, + 4, 4, 4, 50, 51, 51, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, + 0, 8, 8, 8, 8, 8, 0, 0, 0, 8, +}; +static const YYINT demo_check[] = { 42, + 0, 27, 259, 40, 41, 40, 41, 42, 42, 44, + 42, 40, 123, 42, 44, 44, 44, 40, 41, 42, + 41, 44, 41, 44, 59, 44, 42, 42, 41, 59, + 59, 59, 12, 40, 41, 40, 59, 44, 59, 41, + 59, 37, 44, 69, 41, 17, 42, 43, 41, 45, + 44, 47, 59, 41, 91, 43, 91, 45, 264, 265, + 40, 91, 91, 41, 38, 43, 46, 45, 91, 49, + 91, 59, 40, 41, 42, 44, 44, 44, 125, 40, + 123, 59, 125, 267, 91, 57, 91, 67, 123, 91, + 59, 123, 59, 123, 123, 123, 70, 93, 91, 44, + 123, 259, 123, 41, 123, 93, 44, 99, 123, 41, + 102, 36, 60, 259, 59, 93, 123, 42, 269, 44, + 40, 40, 91, 91, 72, 73, 74, 75, 76, 59, + 40, 61, 62, 63, 64, 65, 261, 262, 263, 264, + 265, 89, 37, 68, 269, 259, 94, 42, 43, 37, + 45, 40, 47, 41, 42, 43, 40, 45, 37, 47, + 259, 91, 259, 42, 59, 30, 31, 32, 47, 261, + 262, 263, 264, 265, 266, 268, 259, 269, 4, 90, + 70, 58, 57, 37, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 259, 260, 261, 262, + 263, 264, 265, 266, 259, 259, 269, 259, 260, 261, + 262, 263, 264, 265, 266, -1, 259, 269, 261, 262, + 263, 264, 265, 259, 260, 260, 259, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 259, + -1, 261, 262, 263, 264, 265, -1, -1, -1, 269, +}; +#if YYBTYACC +static const YYINT demo_ctable[] = { -1, + 1, 10, -1, 21, 4, -1, 23, 29, -1, 1, + 51, -1, 101, 56, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 269 +#define YYUNDFTOKEN 301 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const demo_name[] = { + +"$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, +"'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0, +"';'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0, +"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","PREFIX","POSTFIX","ID","CONSTANT","EXTERN", +"REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept", +"input","expr","decl","declarator_list","decl_list","statement", +"statement_list","block_statement","declarator","formal_arg","decl_specs", +"decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list", +"nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8", +"$$9","$$10","$$11","$$12","illegal-symbol", +}; +static const char *const demo_rule[] = { +"$accept : input", +"opt_scope :", +"opt_scope : CLCL", +"opt_scope : opt_scope ID CLCL", +"typename : opt_scope ID", +"$$1 :", +"input : $$1 decl_list", +"decl_list :", +"$$2 :", +"decl_list : decl_list $$2 decl", +"$$3 :", +"decl : decl_specs $$2 $$3 declarator_list ';'", +"$$4 :", +"decl : decl_specs $$2 $$3 declarator $$4 block_statement", +"decl_specs : decl_spec", +"decl_specs : decl_specs $$2 decl_spec", +"cv_quals :", +"cv_quals : cv_quals cv_qual", +"decl_spec : cv_qual", +"decl_spec : typename", +"decl_spec : EXTERN", +"decl_spec : REGISTER", +"decl_spec : STATIC", +"cv_qual : CONST", +"cv_qual : VOLATILE", +"$$5 :", +"$$6 :", +"declarator_list : declarator_list ',' $$5 $$6 declarator", +"declarator_list : declarator", +"declarator :", +"declarator : ID", +"$$7 :", +"$$8 :", +"declarator : '(' $$7 $$8 declarator ')'", +"declarator : '*' cv_quals $$5 $$6 declarator", +"declarator : declarator '[' $$5 expr ']'", +"declarator : declarator '(' $$5 formal_arg_list ')' cv_quals", +"formal_arg_list :", +"formal_arg_list : nonempty_formal_arg_list", +"nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$7 formal_arg", +"nonempty_formal_arg_list : formal_arg", +"formal_arg : decl_specs $$2 $$3 declarator", +"expr : expr '+' $$7 expr", +"expr : expr '-' $$7 expr", +"expr : expr '*' $$7 expr", +"expr : expr '%' $$7 expr", +"expr : expr '/' $$7 expr", +"expr : '*' $$2 expr", +"expr : ID", +"expr : CONSTANT", +"statement : decl", +"$$9 :", +"statement : $$9 expr ';'", +"$$10 :", +"$$11 :", +"statement : IF '(' $$7 expr ')' THEN $$10 statement ELSE $$11 statement", +"statement : IF '(' $$7 expr ')' THEN $$10 statement", +"$$12 :", +"statement : $$12 block_statement", +"statement_list :", +"statement_list : statement_list $$2 statement", +"block_statement : '{' $$2 statement_list '}'", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 200 "btyacc_demo.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); + +extern Scope *global_scope; + +extern Decl * lookup(Scope *scope, char *id); +extern Scope * new_scope(Scope *outer_scope); +extern Scope * start_fn_def(Scope *scope, Decl *fn_decl); +extern void finish_fn_def(Decl *fn_decl, Code *block); +extern Type * type_combine(Type *specs, Type *spec); +extern Type * bare_extern(void); +extern Type * bare_register(void); +extern Type * bare_static(void); +extern Type * bare_const(void); +extern Type * bare_volatile(void); +extern Decl * declare(Scope *scope, char *id, Type *type); +extern Decl * make_pointer(Decl *decl, Type *type); +extern Decl * make_array(Type *type, Expr *expr); +extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type); +extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl); +extern Decl_List * build_dlist(Decl *decl); +extern Expr * build_expr(Expr *left, enum Operator op, Expr *right); +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 638 "btyacc_demo.tab.c" + +/* Release memory associated with symbol. */ +#if ! defined YYDESTRUCT_IS_DECLARED +static void +YYDESTRUCT_DECL() +{ + switch (psymb) + { + case 43: +#line 83 "btyacc_demo.y" + { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 655 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 664 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 673 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 682 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 691 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 700 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 709 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 718 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 727 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 736 "btyacc_demo.tab.c" + case 259: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).id); } + break; +#line 745 "btyacc_demo.tab.c" + case 260: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).expr); } + break; +#line 754 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 763 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 772 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 781 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 790 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 799 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 808 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 817 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 826 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 835 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 844 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 853 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 862 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 871 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 880 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 889 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 898 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 907 "btyacc_demo.tab.c" + case 272: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).expr); } + break; +#line 916 "btyacc_demo.tab.c" + case 273: +#line 67 "btyacc_demo.y" + { /* 'msg' is a 'char *' indicating the context of destructor invocation*/ + printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).decl->scope); free((*val).decl->type); } + break; +#line 926 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 935 "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", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + /* in this example, we don't know what to do here */ } + break; +#line 944 "btyacc_demo.tab.c" + case 276: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).code); } + break; +#line 953 "btyacc_demo.tab.c" + case 277: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).code); } + break; +#line 962 "btyacc_demo.tab.c" + case 278: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).code); } + break; +#line 971 "btyacc_demo.tab.c" + case 279: +#line 73 "btyacc_demo.y" + { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).decl); } + break; +#line 980 "btyacc_demo.tab.c" + case 280: +#line 73 "btyacc_demo.y" + { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).decl); } + break; +#line 989 "btyacc_demo.tab.c" + case 281: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 998 "btyacc_demo.tab.c" + case 282: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 1007 "btyacc_demo.tab.c" + case 283: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 1016 "btyacc_demo.tab.c" + case 284: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 1025 "btyacc_demo.tab.c" + case 285: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 1034 "btyacc_demo.tab.c" + case 286: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1043 "btyacc_demo.tab.c" + case 287: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).dlist); } + break; +#line 1052 "btyacc_demo.tab.c" + case 288: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).dlist); } + break; +#line 1061 "btyacc_demo.tab.c" + case 289: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1070 "btyacc_demo.tab.c" + case 290: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1079 "btyacc_demo.tab.c" + case 291: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 1088 "btyacc_demo.tab.c" + case 292: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1097 "btyacc_demo.tab.c" + case 293: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1106 "btyacc_demo.tab.c" + case 294: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 1115 "btyacc_demo.tab.c" + case 295: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1124 "btyacc_demo.tab.c" + case 296: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).type); } + break; +#line 1133 "btyacc_demo.tab.c" + case 297: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1142 "btyacc_demo.tab.c" + case 298: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1151 "btyacc_demo.tab.c" + case 299: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1160 "btyacc_demo.tab.c" + case 300: +#line 78 "btyacc_demo.y" + { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + (*loc).first_line, (*loc).first_column, + (*loc).last_line, (*loc).last_column); + free((*val).scope); } + break; +#line 1169 "btyacc_demo.tab.c" + } +} +#define YYDESTRUCT_IS_DECLARED 1 +#endif + +/* 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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 93 "btyacc_demo.y" +{ yyval.scope = yystack.l_mark[0].scope; } +break; +case 2: +#line 94 "btyacc_demo.y" +{ yyval.scope = global_scope; } +break; +case 3: +#line 95 "btyacc_demo.y" +{ Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id); + if (!d || !d->scope) YYERROR; + yyval.scope = d->scope; } +break; +case 4: +#line 101 "btyacc_demo.y" +{ Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id); + if (d == NULL || d->istype() == 0) YYERROR; + yyval.type = d->type; } +break; +case 5: +#line 106 "btyacc_demo.y" +yyval.scope = global_scope = new_scope(0); +break; +case 8: +#line 107 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-1].scope; +break; +case 10: +#line 109 "btyacc_demo.y" +yyval.type = yystack.l_mark[-1].type; +break; +case 11: +#line 109 "btyacc_demo.y" +{YYVALID;} +break; +case 12: +#line 110 "btyacc_demo.y" +yyval.scope = start_fn_def(yystack.l_mark[-4].scope, yystack.l_mark[0].decl); +break; +case 13: + if (!yytrial) +#line 111 "btyacc_demo.y" + { /* demonstrate use of @$ & @N, although this is just the + default computation and so is not necessary */ + yyloc.first_line = yystack.p_mark[-5].first_line; + yyloc.first_column = yystack.p_mark[-5].first_column; + yyloc.last_line = yystack.p_mark[0].last_line; + yyloc.last_column = yystack.p_mark[0].last_column; + finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); } +break; +case 14: +#line 121 "btyacc_demo.y" +{ yyval.type = yystack.l_mark[0].type; } +break; +case 15: +#line 122 "btyacc_demo.y" +{ yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); } +break; +case 16: +#line 125 "btyacc_demo.y" +{ yyval.type = 0; } +break; +case 17: +#line 126 "btyacc_demo.y" +{ yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); } +break; +case 18: +#line 130 "btyacc_demo.y" +{ yyval.type = yystack.l_mark[0].type; } +break; +case 19: +#line 131 "btyacc_demo.y" +{ yyval.type = yystack.l_mark[0].type; } +break; +case 20: +#line 132 "btyacc_demo.y" +{ yyval.type = bare_extern(); } +break; +case 21: +#line 133 "btyacc_demo.y" +{ yyval.type = bare_register(); } +break; +case 22: +#line 134 "btyacc_demo.y" +{ yyval.type = bare_static(); } +break; +case 23: +#line 138 "btyacc_demo.y" +{ yyval.type = bare_const(); } +break; +case 24: +#line 139 "btyacc_demo.y" +{ yyval.type = bare_volatile(); } +break; +case 25: +#line 143 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-3].scope; +break; +case 26: +#line 143 "btyacc_demo.y" +yyval.type = yystack.l_mark[-3].type; +break; +case 29: +#line 148 "btyacc_demo.y" +{ if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial) +#line 149 "btyacc_demo.y" +{ yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); } +break; +case 30: + if (!yytrial) +#line 150 "btyacc_demo.y" + { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); } +break; +case 31: +#line 151 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-2].scope; +break; +case 32: +#line 151 "btyacc_demo.y" +yyval.type = yystack.l_mark[-2].type; +break; +case 33: + if (!yytrial) +#line 151 "btyacc_demo.y" + { yyval.decl = yystack.l_mark[-1].decl; } +break; +case 34: + if (!yytrial) +#line 153 "btyacc_demo.y" + { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); } +break; +case 35: + if (!yytrial) +#line 155 "btyacc_demo.y" + { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); } +break; +case 36: + if (!yytrial) +#line 157 "btyacc_demo.y" + { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); } +break; +case 37: + if (!yytrial) +#line 160 "btyacc_demo.y" + { yyval.dlist = 0; } +break; +case 38: + if (!yytrial) +#line 161 "btyacc_demo.y" + { yyval.dlist = yystack.l_mark[0].dlist; } +break; +case 39: + if (!yytrial) +#line 164 "btyacc_demo.y" + { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); } +break; +case 40: + if (!yytrial) +#line 165 "btyacc_demo.y" + { yyval.dlist = build_dlist(yystack.l_mark[0].decl); } +break; +case 41: + if (!yytrial) +#line 168 "btyacc_demo.y" + { yyval.decl = yystack.l_mark[0].decl; } +break; +case 42: + if (!yytrial) +#line 172 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); } +break; +case 43: + if (!yytrial) +#line 173 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); } +break; +case 44: + if (!yytrial) +#line 174 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); } +break; +case 45: + if (!yytrial) +#line 175 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); } +break; +case 46: + if (!yytrial) +#line 176 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); } +break; +case 47: + if (!yytrial) +#line 177 "btyacc_demo.y" + { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); } +break; +case 48: + if (!yytrial) +#line 178 "btyacc_demo.y" + { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); } +break; +case 49: + if (!yytrial) +#line 179 "btyacc_demo.y" + { yyval.expr = yystack.l_mark[0].expr; } +break; +case 50: + if (!yytrial) +#line 183 "btyacc_demo.y" + { yyval.code = 0; } +break; +case 51: +#line 184 "btyacc_demo.y" +yyval.scope = yystack.l_mark[0].scope; +break; +case 52: +#line 184 "btyacc_demo.y" +{YYVALID;} if (!yytrial) +#line 184 "btyacc_demo.y" +{ yyval.code = build_expr_code(yystack.l_mark[-1].expr); } +break; +case 53: +#line 185 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-6].scope; +break; +case 54: +#line 185 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-9].scope; +break; +case 55: +#line 185 "btyacc_demo.y" +{YYVALID;} if (!yytrial) +#line 186 "btyacc_demo.y" +{ yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); } +break; +case 56: +#line 187 "btyacc_demo.y" +{YYVALID;} if (!yytrial) +#line 188 "btyacc_demo.y" +{ yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); } +break; +case 57: +#line 189 "btyacc_demo.y" +yyval.scope = new_scope(yystack.l_mark[0].scope); +break; +case 58: +#line 189 "btyacc_demo.y" +{YYVALID;} if (!yytrial) +#line 189 "btyacc_demo.y" +{ yyval.code = yystack.l_mark[0].code; } +break; +case 59: + if (!yytrial) +#line 192 "btyacc_demo.y" + { yyval.code = 0; } +break; +case 60: + if (!yytrial) +#line 193 "btyacc_demo.y" + { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); } +break; +case 61: + if (!yytrial) +#line 197 "btyacc_demo.y" + { yyval.code = yystack.l_mark[-1].code; } +break; +#line 2097 "btyacc_demo.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/btyacc_demo.tab.h b/contrib/byacc/test/btyacc/btyacc_demo.tab.h new file mode 100644 index 000000000..33139ebeb --- /dev/null +++ b/contrib/byacc/test/btyacc/btyacc_demo.tab.h @@ -0,0 +1,36 @@ +#ifndef _demo__defines_h_ +#define _demo__defines_h_ + +#define PREFIX 257 +#define POSTFIX 258 +#define ID 259 +#define CONSTANT 260 +#define EXTERN 261 +#define REGISTER 262 +#define STATIC 263 +#define CONST 264 +#define VOLATILE 265 +#define IF 266 +#define THEN 267 +#define ELSE 268 +#define CLCL 269 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union { + Scope *scope; + Expr *expr; + Expr_List *elist; + Type *type; + Decl *decl; + Decl_List *dlist; + Code *code; + char *id; + } YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE demo_lval; + +#endif /* _demo__defines_h_ */ diff --git a/contrib/byacc/test/pure_error.tab.h b/contrib/byacc/test/btyacc/calc.error similarity index 100% rename from contrib/byacc/test/pure_error.tab.h rename to contrib/byacc/test/btyacc/calc.error diff --git a/contrib/byacc/test/btyacc/calc.output b/contrib/byacc/test/btyacc/calc.output new file mode 100644 index 000000000..c689eec05 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc.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/contrib/byacc/test/btyacc/calc.tab.c b/contrib/byacc/test/btyacc/calc.tab.c new file mode 100644 index 000000000..ceb2ed101 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc.tab.c @@ -0,0 +1,1431 @@ +/* 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_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 yystos +#define yystos calc_stos +#endif /* yystos */ + +#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 */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 131 "calc.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_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT 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 YYINT calc_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, +}; +static const YYINT calc_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT 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 YYINT 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, +}; +#if YYBTYACC +static const YYINT calc_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_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT 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 YYINT 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 YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_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_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 + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *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 480 "calc.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#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 1197 "calc.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/calc.tab.h b/contrib/byacc/test/btyacc/calc.tab.h new file mode 100644 index 000000000..48f8993b8 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc__defines_h_ +#define _calc__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/calc1.error b/contrib/byacc/test/btyacc/calc1.error new file mode 100644 index 000000000..9c1f7152c --- /dev/null +++ b/contrib/byacc/test/btyacc/calc1.error @@ -0,0 +1,2 @@ +YACC: 2 rules never reduced +YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/calc1.output b/contrib/byacc/test/btyacc/calc1.output new file mode 100644 index 000000000..d6a869f6d --- /dev/null +++ b/contrib/byacc/test/btyacc/calc1.output @@ -0,0 +1,900 @@ + 0 $accept : line $end + + 1 lines : + 2 | lines line + + 3 line : dexp '\n' + 4 | vexp '\n' + 5 | DREG '=' dexp '\n' + 6 | VREG '=' vexp '\n' + 7 | error '\n' + + 8 dexp : CONST + 9 | DREG + 10 | dexp '+' dexp + 11 | dexp '-' dexp + 12 | dexp '*' dexp + 13 | dexp '/' dexp + 14 | '-' dexp + 15 | '(' dexp ')' + + 16 vexp : dexp + 17 | '(' dexp ',' dexp ')' + 18 | VREG + 19 | vexp '+' vexp + 20 | dexp '+' vexp + 21 | vexp '-' vexp + 22 | dexp '-' vexp + 23 | vexp '*' vexp + 24 | dexp '*' vexp + 25 | vexp '/' vexp + 26 | dexp '/' vexp + 27 | '-' vexp + 28 | '(' vexp ')' + +state 0 + $accept : . line $end (0) + + error shift 1 + DREG shift 2 + VREG shift 3 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + line goto 7 + dexp goto 8 + vexp goto 9 + + +state 1 + line : error . '\n' (7) + + '\n' shift 10 + . error + + +state 2 + line : DREG . '=' dexp '\n' (5) + dexp : DREG . (9) + + '=' shift 11 + '+' reduce 9 + '-' reduce 9 + '*' reduce 9 + '/' reduce 9 + '\n' reduce 9 + + +state 3 + line : VREG . '=' vexp '\n' (6) + vexp : VREG . (18) + + '=' shift 12 + '+' reduce 18 + '-' reduce 18 + '*' reduce 18 + '/' reduce 18 + '\n' reduce 18 + + +state 4 + dexp : CONST . (8) + + . reduce 8 + + +state 5 + dexp : '-' . dexp (14) + vexp : '-' . vexp (27) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 15 + vexp goto 16 + + +state 6 + dexp : '(' . dexp ')' (15) + vexp : '(' . dexp ',' dexp ')' (17) + vexp : '(' . vexp ')' (28) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 17 + vexp goto 18 + + +state 7 + $accept : line . $end (0) + + $end accept + + +8: shift/reduce conflict (shift 19, reduce 16) on '+' +8: shift/reduce conflict (shift 20, reduce 16) on '-' +8: shift/reduce conflict (shift 21, reduce 16) on '*' +8: shift/reduce conflict (shift 22, reduce 16) on '/' +8: shift/reduce conflict (shift 23, reduce 16) on '\n' +state 8 + line : dexp . '\n' (3) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + '\n' shift 23 + + +state 9 + line : vexp . '\n' (4) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' shift 28 + . error + + +state 10 + line : error '\n' . (7) + + . reduce 7 + + +state 11 + line : DREG '=' . dexp '\n' (5) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 31 + + +state 12 + line : VREG '=' . vexp '\n' (6) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 33 + + +state 13 + dexp : DREG . (9) + + . reduce 9 + + +state 14 + vexp : VREG . (18) + + . reduce 18 + + +15: reduce/reduce conflict (reduce 14, reduce 16) on '+' +15: reduce/reduce conflict (reduce 14, reduce 16) on '-' +15: reduce/reduce conflict (reduce 14, reduce 16) on '*' +15: reduce/reduce conflict (reduce 14, reduce 16) on '/' +15: reduce/reduce conflict (reduce 14, reduce 16) on '\n' +15: reduce/reduce conflict (reduce 14, reduce 16) on ')' +state 15 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 14 + + +state 16 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '-' vexp . (27) + + . reduce 27 + + +17: shift/reduce conflict (shift 19, reduce 16) on '+' +17: shift/reduce conflict (shift 20, reduce 16) on '-' +17: shift/reduce conflict (shift 21, reduce 16) on '*' +17: shift/reduce conflict (shift 22, reduce 16) on '/' +17: shift/reduce conflict (shift 34, reduce 16) on ')' +state 17 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + vexp : dexp . (16) + vexp : '(' dexp . ',' dexp ')' (17) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + ')' shift 34 + ',' shift 35 + + +state 18 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '(' vexp . ')' (28) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + ')' shift 36 + . error + + +state 19 + dexp : dexp '+' . dexp (10) + vexp : dexp '+' . vexp (20) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 37 + vexp goto 38 + + +state 20 + dexp : dexp '-' . dexp (11) + vexp : dexp '-' . vexp (22) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 39 + vexp goto 40 + + +state 21 + dexp : dexp '*' . dexp (12) + vexp : dexp '*' . vexp (24) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 41 + vexp goto 42 + + +state 22 + dexp : dexp '/' . dexp (13) + vexp : dexp '/' . vexp (26) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 43 + vexp goto 44 + + +state 23 + line : dexp '\n' . (3) + + . reduce 3 + + +state 24 + vexp : vexp '+' . vexp (19) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 45 + + +state 25 + vexp : vexp '-' . vexp (21) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 46 + + +state 26 + vexp : vexp '*' . vexp (23) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 47 + + +state 27 + vexp : vexp '/' . vexp (25) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 48 + + +state 28 + line : vexp '\n' . (4) + + . reduce 4 + + +state 29 + dexp : '-' . dexp (14) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 49 + + +state 30 + dexp : '(' . dexp ')' (15) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 50 + + +state 31 + line : DREG '=' dexp . '\n' (5) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + '\n' shift 55 + . error + + +32: shift/reduce conflict (shift 19, reduce 16) on '+' +32: shift/reduce conflict (shift 20, reduce 16) on '-' +32: shift/reduce conflict (shift 21, reduce 16) on '*' +32: shift/reduce conflict (shift 22, reduce 16) on '/' +state 32 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + '\n' reduce 16 + ')' reduce 16 + + +state 33 + line : VREG '=' vexp . '\n' (6) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' shift 56 + . error + + +state 34 + dexp : '(' dexp ')' . (15) + + . reduce 15 + + +state 35 + vexp : '(' dexp ',' . dexp ')' (17) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 57 + + +state 36 + vexp : '(' vexp ')' . (28) + + . reduce 28 + + +37: reduce/reduce conflict (reduce 10, reduce 16) on '+' +37: reduce/reduce conflict (reduce 10, reduce 16) on '-' +37: shift/reduce conflict (shift 21, reduce 16) on '*' +37: shift/reduce conflict (shift 22, reduce 16) on '/' +37: reduce/reduce conflict (reduce 10, reduce 16) on '\n' +37: reduce/reduce conflict (reduce 10, reduce 16) on ')' +state 37 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' shift 21 + '/' shift 22 + '+' reduce 10 + '-' reduce 10 + '\n' reduce 10 + ')' reduce 10 + ',' reduce 10 + + +state 38 + vexp : vexp . '+' vexp (19) + vexp : dexp '+' vexp . (20) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 20 + '-' reduce 20 + '\n' reduce 20 + ')' reduce 20 + + +39: reduce/reduce conflict (reduce 11, reduce 16) on '+' +39: reduce/reduce conflict (reduce 11, reduce 16) on '-' +39: shift/reduce conflict (shift 21, reduce 16) on '*' +39: shift/reduce conflict (shift 22, reduce 16) on '/' +39: reduce/reduce conflict (reduce 11, reduce 16) on '\n' +39: reduce/reduce conflict (reduce 11, reduce 16) on ')' +state 39 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' shift 21 + '/' shift 22 + '+' reduce 11 + '-' reduce 11 + '\n' reduce 11 + ')' reduce 11 + ',' reduce 11 + + +state 40 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : dexp '-' vexp . (22) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 22 + '-' reduce 22 + '\n' reduce 22 + ')' reduce 22 + + +41: reduce/reduce conflict (reduce 12, reduce 16) on '+' +41: reduce/reduce conflict (reduce 12, reduce 16) on '-' +41: reduce/reduce conflict (reduce 12, reduce 16) on '*' +41: reduce/reduce conflict (reduce 12, reduce 16) on '/' +41: reduce/reduce conflict (reduce 12, reduce 16) on '\n' +41: reduce/reduce conflict (reduce 12, reduce 16) on ')' +state 41 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 12 + + +state 42 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : dexp '*' vexp . (24) + vexp : vexp . '/' vexp (25) + + . reduce 24 + + +43: reduce/reduce conflict (reduce 13, reduce 16) on '+' +43: reduce/reduce conflict (reduce 13, reduce 16) on '-' +43: reduce/reduce conflict (reduce 13, reduce 16) on '*' +43: reduce/reduce conflict (reduce 13, reduce 16) on '/' +43: reduce/reduce conflict (reduce 13, reduce 16) on '\n' +43: reduce/reduce conflict (reduce 13, reduce 16) on ')' +state 43 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 13 + + +state 44 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : dexp '/' vexp . (26) + + . reduce 26 + + +state 45 + vexp : vexp . '+' vexp (19) + vexp : vexp '+' vexp . (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 19 + '-' reduce 19 + '\n' reduce 19 + ')' reduce 19 + + +state 46 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp '-' vexp . (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 21 + '-' reduce 21 + '\n' reduce 21 + ')' reduce 21 + + +state 47 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp '*' vexp . (23) + vexp : vexp . '/' vexp (25) + + . reduce 23 + + +state 48 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : vexp '/' vexp . (25) + + . reduce 25 + + +state 49 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + + . reduce 14 + + +state 50 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 34 + . error + + +state 51 + dexp : dexp '+' . dexp (10) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 58 + + +state 52 + dexp : dexp '-' . dexp (11) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 59 + + +state 53 + dexp : dexp '*' . dexp (12) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 60 + + +state 54 + dexp : dexp '/' . dexp (13) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 61 + + +state 55 + line : DREG '=' dexp '\n' . (5) + + . reduce 5 + + +state 56 + line : VREG '=' vexp '\n' . (6) + + . reduce 6 + + +state 57 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : '(' dexp ',' dexp . ')' (17) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 62 + . error + + +state 58 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 10 + '-' reduce 10 + '\n' reduce 10 + ')' reduce 10 + + +state 59 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 11 + '-' reduce 11 + '\n' reduce 11 + ')' reduce 11 + + +state 60 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + + . reduce 12 + + +state 61 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + + . reduce 13 + + +state 62 + vexp : '(' dexp ',' dexp ')' . (17) + + . reduce 17 + + +Rules never reduced: + lines : (1) + lines : lines line (2) + + +State 8 contains 5 shift/reduce conflicts. +State 15 contains 6 reduce/reduce conflicts. +State 17 contains 5 shift/reduce conflicts. +State 32 contains 4 shift/reduce conflicts. +State 37 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 39 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 41 contains 6 reduce/reduce conflicts. +State 43 contains 6 reduce/reduce conflicts. + + +15 terminals, 5 nonterminals +29 grammar rules, 63 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DREG + 3 258 VREG + 4 259 CONST + 5 43 '+' + 6 45 '-' + 7 42 '*' + 8 47 '/' + 9 260 UMINUS + 10 10 '\n' + 11 61 '=' + 12 40 '(' + 13 41 ')' + 14 44 ',' + 15 261 $accept + 16 262 line + 17 263 dexp + 18 264 vexp + 19 265 lines diff --git a/contrib/byacc/test/btyacc/calc1.tab.c b/contrib/byacc/test/btyacc/calc1.tab.c new file mode 100644 index 000000000..fd86a907a --- /dev/null +++ b/contrib/byacc/test/btyacc/calc1.tab.c @@ -0,0 +1,1677 @@ +/* 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 calc1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc1_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc1_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc1_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc1_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc1_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc1_" + +#define YYPURE 0 + +#line 2 "calc1.y" + +/* http://dinosaur.compilertools.net/yacc/index.html */ + +#include +#include +#include +#include + +typedef struct interval +{ + double lo, hi; +} +INTERVAL; + +INTERVAL vmul(double, double, INTERVAL); +INTERVAL vdiv(double, double, INTERVAL); + +extern int yylex(void); +static void yyerror(const char *s); + +int dcheck(INTERVAL); + +double dreg[26]; +INTERVAL vreg[26]; + +#line 31 "calc1.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 161 "calc1.tab.c" + +/* 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 DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT calc1_lhs[] = { -1, + 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, +}; +static const YYINT calc1_len[] = { 2, + 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, + 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 3, +}; +static const YYINT calc1_defred[] = { 0, + 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, + 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, + 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, + 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, + 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, + 13, 17, +}; +static const YYINT calc1_stos[] = { 0, + 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, + 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, + 42, 47, 10, 43, 45, 42, 47, 10, 45, 40, + 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, + 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, + 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, + 263, 41, +}; +static const YYINT calc1_dgoto[] = { 7, + 32, 9, 0, +}; +static const YYINT calc1_sindex[] = { -40, + -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, + -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, + -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, + 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, + 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, + -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, + 0, 0, +}; +static const YYINT calc1_rindex[] = { 0, + 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, + 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT calc1_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, 0, 0, 0, 0, 0, 0, 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 calc1_gindex[] = { 0, + 4, 124, 0, +}; +#define YYTABLESIZE 225 +static const YYINT calc1_table[] = { 6, + 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, + 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, + 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, + 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, + 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, + 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, + 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, + 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, + 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, + 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, + 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, + 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, + 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, + 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, + 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, + 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, + 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, + 14, 4, 13, 0, 4, +}; +static const YYINT calc1_check[] = { 40, + 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, + 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, + -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, + 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, + 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, + -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, + 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, + 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, + 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, + 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, + 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, + 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, + 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, + 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, + -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, + 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, + 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, + -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -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, 259, 257, + 258, 259, 257, -1, 259, +}; +#define YYFINAL 7 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 260 +#define YYUNDFTOKEN 266 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc1_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,0,0, +"error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines", +"illegal-symbol", +}; +static const char *const calc1_rule[] = { +"$accept : line", +"lines :", +"lines : lines line", +"line : dexp '\\n'", +"line : vexp '\\n'", +"line : DREG '=' dexp '\\n'", +"line : VREG '=' vexp '\\n'", +"line : error '\\n'", +"dexp : CONST", +"dexp : DREG", +"dexp : dexp '+' dexp", +"dexp : dexp '-' dexp", +"dexp : dexp '*' dexp", +"dexp : dexp '/' dexp", +"dexp : '-' dexp", +"dexp : '(' dexp ')'", +"vexp : dexp", +"vexp : '(' dexp ',' dexp ')'", +"vexp : VREG", +"vexp : vexp '+' vexp", +"vexp : dexp '+' vexp", +"vexp : vexp '-' vexp", +"vexp : dexp '-' vexp", +"vexp : vexp '*' vexp", +"vexp : dexp '*' vexp", +"vexp : vexp '/' vexp", +"vexp : dexp '/' vexp", +"vexp : '-' vexp", +"vexp : '(' vexp ')'", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 176 "calc1.y" + /* beginning of subroutines section */ + +#define BSZ 50 /* buffer size for floating point numbers */ + + /* lexical analysis */ + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + int c; + + while ((c = getchar()) == ' ') + { /* skip over blanks */ + } + + if (isupper(c)) + { + yylval.ival = c - 'A'; + return (VREG); + } + if (islower(c)) + { + yylval.ival = c - 'a'; + return (DREG); + } + + if (isdigit(c) || c == '.') + { + /* gobble up digits, points, exponents */ + char buf[BSZ + 1], *cp = buf; + int dot = 0, expr = 0; + + for (; (cp - buf) < BSZ; ++cp, c = getchar()) + { + + *cp = (char) c; + if (isdigit(c)) + continue; + if (c == '.') + { + if (dot++ || expr) + return ('.'); /* will cause syntax error */ + continue; + } + + if (c == 'e') + { + if (expr++) + return ('e'); /* will cause syntax error */ + continue; + } + + /* end of number */ + break; + } + *cp = '\0'; + + if ((cp - buf) >= BSZ) + printf("constant too long: truncated\n"); + else + ungetc(c, stdin); /* push back last char read */ + yylval.dval = atof(buf); + return (CONST); + } + return (c); +} + +static INTERVAL +hilo(double a, double b, double c, double d) +{ + /* returns the smallest interval containing a, b, c, and d */ + /* used by *, / routines */ + INTERVAL v; + + if (a > b) + { + v.hi = a; + v.lo = b; + } + else + { + v.hi = b; + v.lo = a; + } + + if (c > d) + { + if (c > v.hi) + v.hi = c; + if (d < v.lo) + v.lo = d; + } + else + { + if (d > v.hi) + v.hi = d; + if (c < v.lo) + v.lo = c; + } + return (v); +} + +INTERVAL +vmul(double a, double b, INTERVAL v) +{ + return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); +} + +int +dcheck(INTERVAL v) +{ + if (v.hi >= 0. && v.lo <= 0.) + { + printf("divisor interval contains 0.\n"); + return (1); + } + return (0); +} + +INTERVAL +vdiv(double a, double b, INTERVAL v) +{ + return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); +} +#line 623 "calc1.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 57 "calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[-1].dval); + } +break; +case 4: +#line 61 "calc1.y" + { + (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); + } +break; +case 5: +#line 65 "calc1.y" + { + dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; + } +break; +case 6: +#line 69 "calc1.y" + { + vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; + } +break; +case 7: +#line 73 "calc1.y" + { + yyerrok; + } +break; +case 9: +#line 80 "calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; + } +break; +case 10: +#line 84 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +break; +case 11: +#line 88 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +break; +case 12: +#line 92 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +break; +case 13: +#line 96 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +break; +case 14: +#line 100 "calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +break; +case 15: +#line 104 "calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +break; +case 16: +#line 110 "calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +break; +case 17: +#line 114 "calc1.y" + { + yyval.vval.lo = yystack.l_mark[-3].dval; + yyval.vval.hi = yystack.l_mark[-1].dval; + if ( yyval.vval.lo > yyval.vval.hi ) + { + (void) printf("interval out of order\n"); + YYERROR; + } + } +break; +case 18: +#line 124 "calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +break; +case 19: +#line 128 "calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; + } +break; +case 20: +#line 133 "calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; + } +break; +case 21: +#line 138 "calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; + } +break; +case 22: +#line 143 "calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; + } +break; +case 23: +#line 148 "calc1.y" + { + yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 24: +#line 152 "calc1.y" + { + yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 25: +#line 156 "calc1.y" + { + if (dcheck(yystack.l_mark[0].vval)) YYERROR; + yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 26: +#line 161 "calc1.y" + { + if (dcheck ( yystack.l_mark[0].vval )) YYERROR; + yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 27: +#line 166 "calc1.y" + { + yyval.vval.hi = -yystack.l_mark[0].vval.lo; + yyval.vval.lo = -yystack.l_mark[0].vval.hi; + } +break; +case 28: +#line 171 "calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +break; +#line 1443 "calc1.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/calc1.tab.h b/contrib/byacc/test/btyacc/calc1.tab.h new file mode 100644 index 000000000..1802350b0 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc1.tab.h @@ -0,0 +1,23 @@ +#ifndef _calc1__defines_h_ +#define _calc1__defines_h_ + +#define DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE calc1_lval; + +#endif /* _calc1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/calc2.error b/contrib/byacc/test/btyacc/calc2.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/calc2.output b/contrib/byacc/test/btyacc/calc2.output new file mode 100644 index 000000000..c689eec05 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc2.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/contrib/byacc/test/btyacc/calc2.tab.c b/contrib/byacc/test/btyacc/calc2.tab.c new file mode 100644 index 000000000..73e295aae --- /dev/null +++ b/contrib/byacc/test/btyacc/calc2.tab.c @@ -0,0 +1,1444 @@ +/* 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 calc2_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc2_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc2_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc2_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc2_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc2_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc2_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc2_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc2_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc2_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc2_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc2_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc2_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc2_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc2_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc2_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc2_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc2_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc2_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc2_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc2_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc2_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc2_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc2_" + +#define YYPURE 0 + +#line 7 "calc2.y" +# include +# include + +#ifdef YYBISON +#define YYLEX_PARAM base +#define YYLEX_DECL() yylex(int *YYLEX_PARAM) +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +#line 133 "calc2.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(int regs[26], int * base) +#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(int * base) +# define YYLEX yylex(base) +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(regs, base, msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT calc2_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc2_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc2_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 calc2_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, +}; +static const YYINT calc2_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc2_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 calc2_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 calc2_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 calc2_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc2_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 calc2_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 calc2_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 calc2_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 + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "calc2.y" + /* start of programs */ + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main (void) +{ + int regs[26]; + int base = 10; + + while(!feof(stdin)) { + yyparse(regs, &base); + } + return 0; +} + +#define UNUSED(x) ((void)(x)) + +static void +YYERROR_DECL() +{ + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ + fprintf(stderr, "%s\n", s); +} + +int +YYLEX_DECL() +{ + /* 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') % (*base); + return ( DIGIT ); + } + return( c ); +} +#line 493 "calc2.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "calc2.y" + { yyerrok ; } +break; +case 4: +#line 39 "calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "calc2.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "calc2.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "calc2.y" + { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "calc2.y" + { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1210 "calc2.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/calc2.tab.h b/contrib/byacc/test/btyacc/calc2.tab.h new file mode 100644 index 000000000..3f0ce8e79 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc2.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc2__defines_h_ +#define _calc2__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc2__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/calc3.error b/contrib/byacc/test/btyacc/calc3.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/calc3.output b/contrib/byacc/test/btyacc/calc3.output new file mode 100644 index 000000000..c689eec05 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc3.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/contrib/byacc/test/btyacc/calc3.tab.c b/contrib/byacc/test/btyacc/calc3.tab.c new file mode 100644 index 000000000..f1e4bc592 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc3.tab.c @@ -0,0 +1,1449 @@ +/* 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 calc3_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc3_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc3_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc3_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc3_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc3_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc3_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc3_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc3_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc3_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc3_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc3_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc3_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc3_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc3_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc3_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc3_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc3_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc3_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc3_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc3_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc3_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc3_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc3_" + +#define YYPURE 1 + +#line 9 "calc3.y" +# include +# include + +#ifdef YYBISON +#define YYSTYPE int +#define YYLEX_PARAM base +#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM) +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +#line 134 "calc3.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(int regs[26], int * base) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# ifdef YYLEX_PARAM_TYPE +# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) +# else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) +# endif +# define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base) +# define YYLEX yylex(&yylval, base) +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(regs, base, msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT calc3_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc3_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc3_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 calc3_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, +}; +static const YYINT calc3_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc3_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 calc3_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 calc3_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 calc3_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc3_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 calc3_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 calc3_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 calc3_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 + +int yydebug; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 */ +#line 76 "calc3.y" + /* start of programs */ + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main (void) +{ + int regs[26]; + int base = 10; + + while(!feof(stdin)) { + yyparse(regs, &base); + } + return 0; +} + +#define UNUSED(x) ((void)(x)) + +static void +YYERROR_DECL() +{ + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ + fprintf(stderr, "%s\n", s); +} + +int +YYLEX_DECL() +{ + /* 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') % (*base); + return ( DIGIT ); + } + return( c ); +} +#line 448 "calc3.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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 yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* variables for the parser stack */ + 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 short *yylexp = 0; + + static short *yylexemes = 0; +#endif /* YYBTYACC */ + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 38 "calc3.y" + { yyerrok ; } +break; +case 4: +#line 42 "calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 44 "calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 48 "calc3.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 50 "calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 52 "calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 54 "calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 56 "calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 58 "calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 60 "calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 62 "calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 64 "calc3.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 66 "calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 71 "calc3.y" + { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 73 "calc3.y" + { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1215 "calc3.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/calc3.tab.h b/contrib/byacc/test/btyacc/calc3.tab.h new file mode 100644 index 000000000..95fbe0b8d --- /dev/null +++ b/contrib/byacc/test/btyacc/calc3.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc3__defines_h_ +#define _calc3__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc3__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/code_calc.code.c b/contrib/byacc/test/btyacc/code_calc.code.c new file mode 100644 index 000000000..e69ccede6 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_calc.code.c @@ -0,0 +1,1328 @@ +/* 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_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 yystos +#define yystos calc_stos +#endif /* yystos */ + +#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 */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_" + +#define YYPURE 0 + +#line 2 "code_calc.y" +# include +# include + +int regs[26]; +int base; + +#ifdef YYBISON +int yylex(void); +static void yyerror(const char *s); +#endif + +#line 133 "code_calc.code.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 + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +#define YYTABLESIZE 220 +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) + +extern int YYPARSE_DECL(); +typedef short YYINT; +extern const YYINT yylhs[]; +extern const YYINT yylen[]; +extern const YYINT yydefred[]; +extern const YYINT yystos[]; +extern const YYINT yydgoto[]; +extern const YYINT yysindex[]; +extern const YYINT yyrindex[]; +#if YYBTYACC +extern const YYINT yycindex[]; +#endif /* YYBTYACC */ +extern const YYINT yygindex[]; +extern const YYINT yytable[]; +extern const YYINT yycheck[]; +#if YYBTYACC +extern const YYINT yyctable[]; +#endif /* YYBTYACC */ + +#if YYDEBUG +extern const char *const yyname[]; +extern const char *const yyrule[]; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 68 "code_calc.y" + /* start of programs */ + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +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 377 "code_calc.code.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 30 "code_calc.y" + { yyerrok ; } +break; +case 4: +#line 34 "code_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 36 "code_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 40 "code_calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 42 "code_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 44 "code_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 46 "code_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 48 "code_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 50 "code_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 52 "code_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 54 "code_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 56 "code_calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 58 "code_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 63 "code_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 65 "code_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1094 "code_calc.code.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/code_calc.error b/contrib/byacc/test/btyacc/code_calc.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/code_calc.output b/contrib/byacc/test/btyacc/code_calc.output new file mode 100644 index 000000000..c689eec05 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_calc.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/contrib/byacc/test/btyacc/code_calc.tab.c b/contrib/byacc/test/btyacc/code_calc.tab.c new file mode 100644 index 000000000..9ac746a50 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_calc.tab.c @@ -0,0 +1,137 @@ +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +typedef short YYINT; +const YYINT calc_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +const YYINT calc_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +const YYINT 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, +}; +const YYINT calc_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, +}; +const YYINT calc_dgoto[] = { 1, + 7, 8, 9, +}; +const YYINT 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, +}; +const YYINT 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, +}; +#if YYBTYACC +const YYINT calc_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 +const YYINT calc_gindex[] = { 0, + 0, 65, 0, +}; +const YYINT 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, +}; +const YYINT 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, +}; +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#if YYDEBUG +const char *const calc_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", +}; +const char *const calc_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 diff --git a/contrib/byacc/test/btyacc/code_calc.tab.h b/contrib/byacc/test/btyacc/code_calc.tab.h new file mode 100644 index 000000000..48f8993b8 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_calc.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc__defines_h_ +#define _calc__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/code_debug.c b/contrib/byacc/test/btyacc/code_debug.c new file mode 100644 index 000000000..bf0025723 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_debug.c @@ -0,0 +1,1125 @@ +/* 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" +#line 20 "code_debug.c" +#include "rename_debug.i" +#include "rename_debug.h" +typedef short YYINT; +static const YYINT yylhs[] = { -1, + 0, +}; +static const YYINT yylen[] = { 2, + 1, +}; +static const YYINT yydefred[] = { 0, + 1, 0, +}; +static const YYINT yystos[] = { 0, + 256, 258, +}; +static const YYINT yydgoto[] = { 2, +}; +static const YYINT yysindex[] = { -256, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT yycindex[] = { 0, + 0, 0, +}; +#endif +static const YYINT yygindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT yytable[] = { 1, +}; +static const YYINT yycheck[] = { 256, +}; +#if YYBTYACC +static const YYINT yyctable[] = { 0, +}; +#endif +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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", +}; +static const char *const yyrule[] = { +"$accept : S", +"S : error", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 12 "code_debug.y" + +#include + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 236 "code_debug.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/code_debug.error b/contrib/byacc/test/btyacc/code_debug.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/code_debug.h b/contrib/byacc/test/btyacc/code_debug.h new file mode 100644 index 000000000..ba44e7d75 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_debug.h @@ -0,0 +1,6 @@ +#ifndef _yy_defines_h_ +#define _yy_defines_h_ + +#define YYERRCODE 256 + +#endif /* _yy_defines_h_ */ diff --git a/contrib/byacc/test/btyacc/code_debug.i b/contrib/byacc/test/btyacc/code_debug.i new file mode 100644 index 000000000..b8f2144e1 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_debug.i @@ -0,0 +1,60 @@ +#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/contrib/byacc/test/btyacc/code_debug.output b/contrib/byacc/test/btyacc/code_debug.output new file mode 100644 index 000000000..1e56c214a --- /dev/null +++ b/contrib/byacc/test/btyacc/code_debug.output @@ -0,0 +1,34 @@ + 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/contrib/byacc/test/btyacc/code_error.code.c b/contrib/byacc/test/btyacc/code_error.code.c new file mode 100644 index 000000000..5fceee507 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_error.code.c @@ -0,0 +1,1239 @@ +/* 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 error_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex error_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror error_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar error_char +#endif /* yychar */ + +#ifndef yyval +#define yyval error_val +#endif /* yyval */ + +#ifndef yylval +#define yylval error_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug error_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs error_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag error_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs error_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen error_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred error_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos error_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto error_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex error_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex error_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex error_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable error_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck error_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname error_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule error_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex error_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable error_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "error_" + +#define YYPURE 0 + +#line 2 "code_error.y" + +#ifdef YYBISON +int yylex(void); +static void yyerror(const char *); +#endif + +#line 128 "code_error.code.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 + +#define YYERRCODE 256 +#define YYTABLESIZE 0 +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) + +extern int YYPARSE_DECL(); +typedef short YYINT; +extern const YYINT yylhs[]; +extern const YYINT yylen[]; +extern const YYINT yydefred[]; +extern const YYINT yystos[]; +extern const YYINT yydgoto[]; +extern const YYINT yysindex[]; +extern const YYINT yyrindex[]; +#if YYBTYACC +extern const YYINT yycindex[]; +#endif /* YYBTYACC */ +extern const YYINT yygindex[]; +extern const YYINT yytable[]; +extern const YYINT yycheck[]; +#if YYBTYACC +extern const YYINT yyctable[]; +#endif /* YYBTYACC */ + +#if YYDEBUG +extern const char *const yyname[]; +extern const char *const yyrule[]; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 12 "code_error.y" + +#include + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 349 "code_error.code.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/code_error.error b/contrib/byacc/test/btyacc/code_error.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/code_error.output b/contrib/byacc/test/btyacc/code_error.output new file mode 100644 index 000000000..1e56c214a --- /dev/null +++ b/contrib/byacc/test/btyacc/code_error.output @@ -0,0 +1,34 @@ + 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/contrib/byacc/test/btyacc/code_error.tab.c b/contrib/byacc/test/btyacc/code_error.tab.c new file mode 100644 index 000000000..3a66ac6ad --- /dev/null +++ b/contrib/byacc/test/btyacc/code_error.tab.c @@ -0,0 +1,55 @@ +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +typedef short YYINT; +const YYINT error_lhs[] = { -1, + 0, +}; +const YYINT error_len[] = { 2, + 1, +}; +const YYINT error_defred[] = { 0, + 1, 0, +}; +const YYINT error_stos[] = { 0, + 256, 258, +}; +const YYINT error_dgoto[] = { 2, +}; +const YYINT error_sindex[] = { -256, + 0, 0, +}; +const YYINT error_rindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +const YYINT error_cindex[] = { 0, + 0, 0, +}; +#endif +const YYINT error_gindex[] = { 0, +}; +const YYINT error_table[] = { 1, +}; +const YYINT error_check[] = { 256, +}; +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#if YYDEBUG +const char *const error_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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", +}; +const char *const error_rule[] = { +"$accept : S", +"S : error", + +}; +#endif diff --git a/contrib/byacc/test/btyacc/code_error.tab.h b/contrib/byacc/test/btyacc/code_error.tab.h new file mode 100644 index 000000000..f9e5ad278 --- /dev/null +++ b/contrib/byacc/test/btyacc/code_error.tab.h @@ -0,0 +1,5 @@ +#ifndef _error__defines_h_ +#define _error__defines_h_ + + +#endif /* _error__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/empty.error b/contrib/byacc/test/btyacc/empty.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/empty.output b/contrib/byacc/test/btyacc/empty.output new file mode 100644 index 000000000..bb2b6a9e3 --- /dev/null +++ b/contrib/byacc/test/btyacc/empty.output @@ -0,0 +1,28 @@ + 0 $accept : start $end + + 1 start : + +state 0 + $accept : . start $end (0) + start : . (1) + + . reduce 1 + + start goto 1 + + +state 1 + $accept : start . $end (0) + + $end accept + + +2 terminals, 2 nonterminals +2 grammar rules, 2 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 $accept + 3 258 start diff --git a/contrib/byacc/test/btyacc/empty.tab.c b/contrib/byacc/test/btyacc/empty.tab.c new file mode 100644 index 000000000..cb487f743 --- /dev/null +++ b/contrib/byacc/test/btyacc/empty.tab.c @@ -0,0 +1,1254 @@ +/* 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 empty_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex empty_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror empty_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar empty_char +#endif /* yychar */ + +#ifndef yyval +#define yyval empty_val +#endif /* yyval */ + +#ifndef yylval +#define yylval empty_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug empty_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs empty_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag empty_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs empty_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen empty_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred empty_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos empty_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto empty_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex empty_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex empty_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex empty_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable empty_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck empty_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname empty_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule empty_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex empty_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable empty_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "empty_" + +#define YYPURE 0 + +#line 2 "empty.y" +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +static int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif +#line 128 "empty.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 YYERRCODE 256 +typedef short YYINT; +static const YYINT empty_lhs[] = { -1, + 0, +}; +static const YYINT empty_len[] = { 2, + 0, +}; +static const YYINT empty_defred[] = { 1, + 0, +}; +static const YYINT empty_stos[] = { 0, + 258, +}; +static const YYINT empty_dgoto[] = { 1, +}; +static const YYINT empty_sindex[] = { 0, + 0, +}; +static const YYINT empty_rindex[] = { 0, + 0, +}; +#if YYBTYACC +static const YYINT empty_cindex[] = { 0, + 0, +}; +#endif +static const YYINT empty_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT empty_table[] = { 0, +}; +static const YYINT empty_check[] = { -1, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const empty_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","start", +"illegal-symbol", +}; +static const char *const empty_rule[] = { +"$accept : start", +"start :", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 13 "empty.y" + +#include + +static int +YYLEX_DECL() { + return -1; +} + +static void +YYERROR_DECL() { + printf("%s\n",s); +} +#line 364 "empty.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/empty.tab.h b/contrib/byacc/test/btyacc/empty.tab.h new file mode 100644 index 000000000..14683cfea --- /dev/null +++ b/contrib/byacc/test/btyacc/empty.tab.h @@ -0,0 +1,5 @@ +#ifndef _empty__defines_h_ +#define _empty__defines_h_ + + +#endif /* _empty__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_inherit1.error b/contrib/byacc/test/btyacc/err_inherit1.error new file mode 100644 index 000000000..1d662b649 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit1.error @@ -0,0 +1,3 @@ +YACC: e - line 64 of "./test/err_inherit1.y", unterminated argument list +namelist($c, $t + ^ diff --git a/contrib/byacc/test/btyacc/err_inherit1.output b/contrib/byacc/test/btyacc/err_inherit1.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_inherit1.tab.c b/contrib/byacc/test/btyacc/err_inherit1.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit1.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_inherit1.tab.h b/contrib/byacc/test/btyacc/err_inherit1.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_inherit2.error b/contrib/byacc/test/btyacc/err_inherit2.error new file mode 100644 index 000000000..a3fa54a4f --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit2.error @@ -0,0 +1,5 @@ +YACC: w - line 64 of "./test/err_inherit2.y", number of arguments of namelist doesn't agree with previous declaration +YACC: w - line 64 of "./test/err_inherit2.y", type of argument 1 to namelist doesn't agree with previous declaration +YACC: e - line 64 of "./test/err_inherit2.y", bad formal argument list +namelist($c, $t, extra): namelist NAME + ^ diff --git a/contrib/byacc/test/btyacc/err_inherit2.output b/contrib/byacc/test/btyacc/err_inherit2.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_inherit2.tab.c b/contrib/byacc/test/btyacc/err_inherit2.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit2.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_inherit2.tab.h b/contrib/byacc/test/btyacc/err_inherit2.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_inherit3.error b/contrib/byacc/test/btyacc/err_inherit3.error new file mode 100644 index 000000000..6e27dd050 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit3.error @@ -0,0 +1,23 @@ +YACC: w - line 64 of "./test/err_inherit3.y", number of arguments of namelist doesn't agree with previous declaration +YACC: w - line 64 of "./test/err_inherit3.y", wrong number of arguments for namelist +namelist: namelist($c) NAME + ^ +YACC: w - line 64 of "./test/err_inherit3.y", unknown argument $c +YACC: w - line 64 of "./test/err_inherit3.y", untyped argument $c +YACC: w - line 65 of "./test/err_inherit3.y", unknown argument $t + { $$->s = mksymbol($t, $c, $2); + ^ +YACC: w - line 65 of "./test/err_inherit3.y", unknown argument $c + { $$->s = mksymbol($t, $c, $2); + ^ +YACC: w - line 69 of "./test/err_inherit3.y", unknown argument $t + { $$->s = mksymbol($t, $c, $1); + ^ +YACC: w - line 69 of "./test/err_inherit3.y", untyped argument $t +YACC: w - line 69 of "./test/err_inherit3.y", unknown argument $c + { $$->s = mksymbol($t, $c, $1); + ^ +YACC: w - line 69 of "./test/err_inherit3.y", untyped argument $c +YACC: w - line 0 of "./test/err_inherit3.y", start symbol declaration requires arguments +YACC: 1 rule never reduced +YACC: 3 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/err_inherit3.output b/contrib/byacc/test/btyacc/err_inherit3.output new file mode 100644 index 000000000..16ea531b8 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit3.output @@ -0,0 +1,229 @@ + 0 $accept : declaration $end + + 1 $$1 : + + 2 $$2 : + + 3 declaration : class type $$1 $$2 namelist + + 4 $$3 : + + 5 declaration : type $$3 locnamelist + + 6 class : GLOBAL + 7 | LOCAL + + 8 type : REAL + 9 | INTEGER + + 10 $$4 : + + 11 namelist : $$4 namelist NAME + 12 | NAME + + 13 $$5 : + + 14 locnamelist : $$5 $$2 namelist + +state 0 + $accept : . declaration $end (0) + + GLOBAL shift 1 + LOCAL shift 2 + REAL shift 3 + INTEGER shift 4 + . error + + declaration goto 5 + class goto 6 + type goto 7 + + +state 1 + class : GLOBAL . (6) + + . reduce 6 + + +state 2 + class : LOCAL . (7) + + . reduce 7 + + +state 3 + type : REAL . (8) + + . reduce 8 + + +state 4 + type : INTEGER . (9) + + . reduce 9 + + +state 5 + $accept : declaration . $end (0) + + $end accept + + +state 6 + declaration : class . type $$1 $$2 namelist (3) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . $$3 locnamelist (5) + $$3 : . (4) + + . reduce 4 + + $$3 goto 9 + + +state 8 + declaration : class type . $$1 $$2 namelist (3) + $$1 : . (1) + + . reduce 1 + + $$1 goto 10 + + +state 9 + declaration : type $$3 . locnamelist (5) + $$5 : . (13) + + . reduce 13 + + locnamelist goto 11 + $$5 goto 12 + + +state 10 + declaration : class type $$1 . $$2 namelist (3) + $$2 : . (2) + + . reduce 2 + + $$2 goto 13 + + +state 11 + declaration : type $$3 locnamelist . (5) + + . reduce 5 + + +state 12 + locnamelist : $$5 . $$2 namelist (14) + $$2 : . (2) + + . reduce 2 + + $$2 goto 14 + + +13: shift/reduce conflict (shift 15, reduce 10) on NAME +state 13 + declaration : class type $$1 $$2 . namelist (3) + $$4 : . (10) + + NAME shift 15 + + namelist goto 16 + $$4 goto 17 + + +14: shift/reduce conflict (shift 15, reduce 10) on NAME +state 14 + locnamelist : $$5 $$2 . namelist (14) + $$4 : . (10) + + NAME shift 15 + + namelist goto 18 + $$4 goto 17 + + +state 15 + namelist : NAME . (12) + + . reduce 12 + + +state 16 + declaration : class type $$1 $$2 namelist . (3) + + . reduce 3 + + +17: shift/reduce conflict (shift 15, reduce 10) on NAME +state 17 + namelist : $$4 . namelist NAME (11) + $$4 : . (10) + + NAME shift 15 + + namelist goto 19 + $$4 goto 17 + + +state 18 + locnamelist : $$5 $$2 namelist . (14) + + . reduce 14 + + +state 19 + namelist : $$4 namelist . NAME (11) + + NAME shift 20 + . error + + +state 20 + namelist : $$4 namelist NAME . (11) + + . reduce 11 + + +Rules never reduced: + $$4 : (10) + + +State 13 contains 1 shift/reduce conflict. +State 14 contains 1 shift/reduce conflict. +State 17 contains 1 shift/reduce conflict. + + +7 terminals, 11 nonterminals +15 grammar rules, 21 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 GLOBAL + 3 258 LOCAL + 4 259 REAL + 5 260 INTEGER + 6 261 NAME + 7 262 $accept + 8 263 declaration + 9 264 namelist + 10 265 locnamelist + 11 266 class + 12 267 type + 13 268 $$1 + 14 269 $$2 + 15 270 $$3 + 16 271 $$4 + 17 272 $$5 diff --git a/contrib/byacc/test/btyacc/err_inherit3.tab.c b/contrib/byacc/test/btyacc/err_inherit3.tab.c new file mode 100644 index 000000000..58b317710 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit3.tab.c @@ -0,0 +1,1414 @@ +/* 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 err_inherit3_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_inherit3_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_inherit3_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_inherit3_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_inherit3_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_inherit3_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_inherit3_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_inherit3_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_inherit3_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_inherit3_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_inherit3_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_inherit3_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos err_inherit3_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto err_inherit3_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_inherit3_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_inherit3_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_inherit3_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_inherit3_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_inherit3_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_inherit3_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_inherit3_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex err_inherit3_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable err_inherit3_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "err_inherit3_" + +#define YYPURE 0 + +#line 2 "err_inherit3.y" +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +#line 39 "err_inherit3.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 155 "err_inherit3.tab.c" + +/* 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 + +#ifndef YYDESTRUCT_DECL +#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val) +#endif +#ifndef YYDESTRUCT_CALL +#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val) +#endif + +extern int YYPARSE_DECL(); + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT err_inherit3_lhs[] = { -1, + 5, 6, 0, 7, 0, 3, 3, 4, 4, 8, + 1, 1, 9, 2, +}; +static const YYINT err_inherit3_len[] = { 2, + 0, 0, 5, 0, 3, 1, 1, 1, 1, 0, + 3, 1, 0, 3, +}; +static const YYINT err_inherit3_defred[] = { 0, + 6, 7, 8, 9, 0, 0, 4, 1, 13, 2, + 5, 2, 0, 0, 12, 3, 0, 14, 0, 11, +}; +static const YYINT err_inherit3_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 270, 268, + 265, 272, 269, 269, 261, 264, 271, 264, 264, 261, +}; +static const YYINT err_inherit3_dgoto[] = { 5, + 16, 11, 6, 7, 10, 13, 9, 17, 12, +}; +static const YYINT err_inherit3_sindex[] = { -257, + 0, 0, 0, 0, 0, -254, 0, 0, 0, 0, + 0, 0, -253, -253, 0, 0, -253, 0, -252, 0, +}; +static const YYINT err_inherit3_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +#if YYBTYACC +static const YYINT err_inherit3_cindex[] = { 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 err_inherit3_gindex[] = { 0, + -10, 0, 0, 4, 0, -1, 0, 0, 0, +}; +#define YYTABLESIZE 11 +static const YYINT err_inherit3_table[] = { 1, + 2, 3, 4, 18, 3, 4, 19, 15, 20, 8, + 14, +}; +static const YYINT err_inherit3_check[] = { 257, + 258, 259, 260, 14, 259, 260, 17, 261, 261, 6, + 12, +}; +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 273 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_inherit3_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","GLOBAL","LOCAL","REAL","INTEGER", +"NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", +"$$2","$$3","$$4","$$5","illegal-symbol", +}; +static const char *const err_inherit3_rule[] = { +"$accept : declaration", +"$$1 :", +"$$2 :", +"declaration : class type $$1 $$2 namelist", +"$$3 :", +"declaration : type $$3 locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"$$4 :", +"namelist : $$4 namelist NAME", +"namelist : NAME", +"$$5 :", +"locnamelist : $$5 $$2 namelist", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 78 "err_inherit3.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 415 "err_inherit3.tab.c" + +/* Release memory associated with symbol. */ +#if ! defined YYDESTRUCT_IS_DECLARED +static void +YYDESTRUCT_DECL() +{ + switch (psymb) + { + case 263: +#line 30 "err_inherit3.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + break; +#line 435 "err_inherit3.tab.c" + case 264: +#line 30 "err_inherit3.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + break; +#line 447 "err_inherit3.tab.c" + case 265: +#line 30 "err_inherit3.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + break; +#line 459 "err_inherit3.tab.c" + } +} +#define YYDESTRUCT_IS_DECLARED 1 +#endif + +/* 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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 50 "err_inherit3.y" +yyval.cval = yystack.l_mark[-1].cval; +break; +case 2: +#line 50 "err_inherit3.y" +yyval.tval = yystack.l_mark[-1].tval; +break; +case 3: +#line 51 "err_inherit3.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 4: +#line 52 "err_inherit3.y" +yyval.tval = yystack.l_mark[0].tval; +break; +case 5: +#line 53 "err_inherit3.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 6: +#line 56 "err_inherit3.y" + { yyval.cval = cGLOBAL; } +break; +case 7: +#line 57 "err_inherit3.y" + { yyval.cval = cLOCAL; } +break; +case 8: +#line 60 "err_inherit3.y" + { yyval.tval = tREAL; } +break; +case 9: +#line 61 "err_inherit3.y" + { yyval.tval = tINTEGER; } +break; +case 10: +#line 64 "err_inherit3.y" +yyval.cval = yystack.l_mark[-2]; +break; +case 11: +#line 65 "err_inherit3.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-5].tval, yystack.l_mark[-5].cval, yystack.l_mark[0].id); + yyval.nlist->next = yystack.l_mark[-1].nlist; + } +break; +case 12: +#line 69 "err_inherit3.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-3], yystack.l_mark[-3], yystack.l_mark[0].id); + yyval.nlist->next = NULL; + } +break; +case 13: +#line 74 "err_inherit3.y" +yyval.cval = cLOCAL; +break; +case 14: +#line 75 "err_inherit3.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +#line 1180 "err_inherit3.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/err_inherit3.tab.h b/contrib/byacc/test/btyacc/err_inherit3.tab.h new file mode 100644 index 000000000..5fa781de3 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit3.tab.h @@ -0,0 +1,25 @@ +#ifndef _err_inherit3__defines_h_ +#define _err_inherit3__defines_h_ + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE err_inherit3_lval; + +#endif /* _err_inherit3__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_inherit4.error b/contrib/byacc/test/btyacc/err_inherit4.error new file mode 100644 index 000000000..00eb9890a --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit4.error @@ -0,0 +1,13 @@ +YACC: w - line 32 of "./test/err_inherit4.y", destructor redeclared +%destructor { + ^ +YACC: w - line 77 of "./test/err_inherit4.y", wrong number of default arguments for namelist + { $$ = $1; @$ = @2; } + ^ +YACC: w - line 77 of "./test/err_inherit4.y", wrong type for default argument 2 to namelist + { $$ = $1; @$ = @2; } + ^ +YACC: w - line 77 of "./test/err_inherit4.y", wrong type for default argument 1 to namelist + { $$ = $1; @$ = @2; } + ^ +YACC: w - line 77 of "./test/err_inherit4.y", @2 references beyond the end of the current rule diff --git a/contrib/byacc/test/btyacc/err_inherit4.output b/contrib/byacc/test/btyacc/err_inherit4.output new file mode 100644 index 000000000..f52c28769 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit4.output @@ -0,0 +1,178 @@ + 0 $accept : declaration $end + + 1 $$1 : + + 2 $$2 : + + 3 declaration : class type $$1 $$2 namelist + + 4 $$3 : + + 5 declaration : type $$3 locnamelist + + 6 class : GLOBAL + 7 | LOCAL + + 8 type : REAL + 9 | INTEGER + + 10 namelist : namelist NAME + 11 | NAME + + 12 locnamelist : namelist + +state 0 + $accept : . declaration $end (0) + + GLOBAL shift 1 + LOCAL shift 2 + REAL shift 3 + INTEGER shift 4 + . error + + declaration goto 5 + class goto 6 + type goto 7 + + +state 1 + class : GLOBAL . (6) + + . reduce 6 + + +state 2 + class : LOCAL . (7) + + . reduce 7 + + +state 3 + type : REAL . (8) + + . reduce 8 + + +state 4 + type : INTEGER . (9) + + . reduce 9 + + +state 5 + $accept : declaration . $end (0) + + $end accept + + +state 6 + declaration : class . type $$1 $$2 namelist (3) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . $$3 locnamelist (5) + $$3 : . (4) + + . reduce 4 + + $$3 goto 9 + + +state 8 + declaration : class type . $$1 $$2 namelist (3) + $$1 : . (1) + + . reduce 1 + + $$1 goto 10 + + +state 9 + declaration : type $$3 . locnamelist (5) + + NAME shift 11 + . error + + namelist goto 12 + locnamelist goto 13 + + +state 10 + declaration : class type $$1 . $$2 namelist (3) + $$2 : . (2) + + . reduce 2 + + $$2 goto 14 + + +state 11 + namelist : NAME . (11) + + . reduce 11 + + +state 12 + namelist : namelist . NAME (10) + locnamelist : namelist . (12) + + NAME shift 15 + $end reduce 12 + + +state 13 + declaration : type $$3 locnamelist . (5) + + . reduce 5 + + +state 14 + declaration : class type $$1 $$2 . namelist (3) + + NAME shift 11 + . error + + namelist goto 16 + + +state 15 + namelist : namelist NAME . (10) + + . reduce 10 + + +state 16 + declaration : class type $$1 $$2 namelist . (3) + namelist : namelist . NAME (10) + + NAME shift 15 + $end reduce 3 + + +7 terminals, 9 nonterminals +13 grammar rules, 17 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 GLOBAL + 3 258 LOCAL + 4 259 REAL + 5 260 INTEGER + 6 261 NAME + 7 262 $accept + 8 263 declaration + 9 264 namelist + 10 265 locnamelist + 11 266 class + 12 267 type + 13 268 $$1 + 14 269 $$2 + 15 270 $$3 diff --git a/contrib/byacc/test/btyacc/err_inherit4.tab.c b/contrib/byacc/test/btyacc/err_inherit4.tab.c new file mode 100644 index 000000000..dfbb1724f --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit4.tab.c @@ -0,0 +1,1403 @@ +/* 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 err_inherit4_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_inherit4_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_inherit4_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_inherit4_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_inherit4_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_inherit4_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_inherit4_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_inherit4_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_inherit4_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_inherit4_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_inherit4_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_inherit4_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos err_inherit4_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto err_inherit4_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_inherit4_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_inherit4_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_inherit4_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_inherit4_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_inherit4_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_inherit4_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_inherit4_rule +#endif /* yyrule */ + +#ifndef yyloc +#define yyloc err_inherit4_loc +#endif /* yyloc */ + +#ifndef yylloc +#define yylloc err_inherit4_lloc +#endif /* yylloc */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex err_inherit4_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable err_inherit4_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "err_inherit4_" + +#define YYPURE 0 + +#line 3 "err_inherit4.y" +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +#line 41 "err_inherit4.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 163 "err_inherit4.tab.c" + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +/* Default: YYLTYPE is the text position type. */ +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +#define YYLTYPE_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(YYLTYPE loc, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(yylloc, msg) +#endif + +#ifndef YYDESTRUCT_DECL +#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc) +#endif +#ifndef YYDESTRUCT_CALL +#define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc) +#endif + +extern int YYPARSE_DECL(); + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT err_inherit4_lhs[] = { -1, + 5, 6, 0, 7, 0, 3, 3, 4, 4, 1, + 1, 2, +}; +static const YYINT err_inherit4_len[] = { 2, + 0, 0, 5, 0, 3, 1, 1, 1, 1, 2, + 1, 1, +}; +static const YYINT err_inherit4_defred[] = { 0, + 6, 7, 8, 9, 0, 0, 4, 1, 0, 2, + 11, 0, 5, 0, 10, 0, +}; +static const YYINT err_inherit4_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 270, 268, + 261, 264, 265, 269, 261, 264, +}; +static const YYINT err_inherit4_dgoto[] = { 5, + 12, 13, 6, 7, 10, 14, 9, +}; +static const YYINT err_inherit4_sindex[] = { -257, + 0, 0, 0, 0, 0, -255, 0, 0, -254, 0, + 0, -253, 0, -254, 0, -253, +}; +static const YYINT err_inherit4_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6, 0, 0, 0, 9, +}; +#if YYBTYACC +static const YYINT err_inherit4_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, +}; +#endif +static const YYINT err_inherit4_gindex[] = { 0, + -4, 0, 0, 5, 0, 0, 0, +}; +#define YYTABLESIZE 11 +static const YYINT err_inherit4_table[] = { 1, + 2, 3, 4, 3, 4, 12, 11, 15, 3, 16, + 8, +}; +static const YYINT err_inherit4_check[] = { 257, + 258, 259, 260, 259, 260, 0, 261, 261, 0, 14, + 6, +}; +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 271 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_inherit4_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","GLOBAL","LOCAL","REAL","INTEGER", +"NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", +"$$2","$$3","illegal-symbol", +}; +static const char *const err_inherit4_rule[] = { +"$accept : declaration", +"$$1 :", +"$$2 :", +"declaration : class type $$1 $$2 namelist", +"$$3 :", +"declaration : type $$3 locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"locnamelist : namelist", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 80 "err_inherit4.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 433 "err_inherit4.tab.c" + +/* Release memory associated with symbol. */ +#if ! defined YYDESTRUCT_IS_DECLARED +static void +YYDESTRUCT_DECL() +{ + switch (psymb) + { + case 263: +#line 28 "err_inherit4.y" + { } + break; +#line 446 "err_inherit4.tab.c" + case 264: +#line 28 "err_inherit4.y" + { } + break; +#line 451 "err_inherit4.tab.c" + case 265: +#line 28 "err_inherit4.y" + { } + break; +#line 456 "err_inherit4.tab.c" + } +} +#define YYDESTRUCT_IS_DECLARED 1 +#endif + +/* 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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 52 "err_inherit4.y" +yyval.cval = yystack.l_mark[-1].cval; +break; +case 2: +#line 52 "err_inherit4.y" +yyval.tval = yystack.l_mark[-1].tval; +break; +case 3: +#line 53 "err_inherit4.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 4: +#line 54 "err_inherit4.y" +yyval.tval = yystack.l_mark[0].tval; +break; +case 5: +#line 55 "err_inherit4.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 6: +#line 58 "err_inherit4.y" + { yyval.cval = cGLOBAL; } +break; +case 7: +#line 59 "err_inherit4.y" + { yyval.cval = cLOCAL; } +break; +case 8: +#line 62 "err_inherit4.y" + { yyval.tval = tREAL; } +break; +case 9: +#line 63 "err_inherit4.y" + { yyval.tval = tINTEGER; } +break; +case 10: +#line 67 "err_inherit4.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id); + yyval.nlist->next = yystack.l_mark[-1].nlist; + } +break; +case 11: +#line 71 "err_inherit4.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); + yyval.nlist->next = NULL; + } +break; +case 12: +#line 77 "err_inherit4.y" + { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; } +break; +#line 1169 "err_inherit4.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/err_inherit4.tab.h b/contrib/byacc/test/btyacc/err_inherit4.tab.h new file mode 100644 index 000000000..5561fd858 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit4.tab.h @@ -0,0 +1,25 @@ +#ifndef _err_inherit4__defines_h_ +#define _err_inherit4__defines_h_ + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE err_inherit4_lval; + +#endif /* _err_inherit4__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_inherit5.error b/contrib/byacc/test/btyacc/err_inherit5.error new file mode 100644 index 000000000..edc58c984 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit5.error @@ -0,0 +1 @@ +YACC: e - line 74 of "./test/err_inherit5.y", illegal @$ or @N reference diff --git a/contrib/byacc/test/btyacc/err_inherit5.output b/contrib/byacc/test/btyacc/err_inherit5.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_inherit5.tab.c b/contrib/byacc/test/btyacc/err_inherit5.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_inherit5.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_inherit5.tab.h b/contrib/byacc/test/btyacc/err_inherit5.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax1.error b/contrib/byacc/test/btyacc/err_syntax1.error new file mode 100644 index 000000000..e3a341d4e --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax1.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./test/err_syntax1.y", syntax error + ?% { + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax1.output b/contrib/byacc/test/btyacc/err_syntax1.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax1.tab.c b/contrib/byacc/test/btyacc/err_syntax1.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax1.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax1.tab.h b/contrib/byacc/test/btyacc/err_syntax1.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax10.error b/contrib/byacc/test/btyacc/err_syntax10.error new file mode 100644 index 000000000..ceb876ec6 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax10.error @@ -0,0 +1,3 @@ +YACC: w - line 7 of "./test/err_syntax10.y", the type of '(' has been redeclared +YACC: w - line 7 of "./test/err_syntax10.y", the type of '*' has been redeclared +YACC: w - line 7 of "./test/err_syntax10.y", the type of '&' has been redeclared diff --git a/contrib/byacc/test/btyacc/err_syntax10.output b/contrib/byacc/test/btyacc/err_syntax10.output new file mode 100644 index 000000000..3d9210a70 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax10.output @@ -0,0 +1,37 @@ + 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 + + +5 terminals, 2 nonterminals +2 grammar rules, 3 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 40 '(' + 3 42 '*' + 4 38 '&' + 5 257 $accept + 6 258 S diff --git a/contrib/byacc/test/btyacc/err_syntax10.tab.c b/contrib/byacc/test/btyacc/err_syntax10.tab.c new file mode 100644 index 000000000..5c8645320 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax10.tab.c @@ -0,0 +1,1253 @@ +/* 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 err_syntax10_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax10_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax10_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax10_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax10_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax10_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax10_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax10_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax10_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax10_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax10_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax10_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos err_syntax10_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto err_syntax10_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax10_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax10_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax10_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax10_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax10_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax10_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax10_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex err_syntax10_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable err_syntax10_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "err_syntax10_" + +#define YYPURE 0 + +#line 2 "err_syntax10.y" +int yylex(void); +static void yyerror(const char *); +#line 124 "err_syntax10.tab.c" + +/* 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 YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax10_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax10_len[] = { 2, + 1, +}; +static const YYINT err_syntax10_defred[] = { 0, + 1, 0, +}; +static const YYINT err_syntax10_stos[] = { 0, + 256, 258, +}; +static const YYINT err_syntax10_dgoto[] = { 2, +}; +static const YYINT err_syntax10_sindex[] = { -256, + 0, 0, +}; +static const YYINT err_syntax10_rindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT err_syntax10_cindex[] = { 0, + 0, 0, +}; +#endif +static const YYINT err_syntax10_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT err_syntax10_table[] = { 1, +}; +static const YYINT err_syntax10_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax10_name[] = { + +"$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, +0,"'&'",0,"'('",0,"'*'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,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", +}; +static const char *const err_syntax10_rule[] = { +"$accept : S", +"S : error", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 12 "err_syntax10.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 363 "err_syntax10.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/err_syntax10.tab.h b/contrib/byacc/test/btyacc/err_syntax10.tab.h new file mode 100644 index 000000000..b9f412593 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax10.tab.h @@ -0,0 +1,5 @@ +#ifndef _err_syntax10__defines_h_ +#define _err_syntax10__defines_h_ + + +#endif /* _err_syntax10__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_syntax11.error b/contrib/byacc/test/btyacc/err_syntax11.error new file mode 100644 index 000000000..df0aee4fb --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax11.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./test/err_syntax11.y", the precedence of '|' has been redeclared diff --git a/contrib/byacc/test/btyacc/err_syntax11.output b/contrib/byacc/test/btyacc/err_syntax11.output new file mode 100644 index 000000000..bc5e66d98 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax11.output @@ -0,0 +1,35 @@ + 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 + + +3 terminals, 2 nonterminals +2 grammar rules, 3 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 124 '|' + 3 257 $accept + 4 258 S diff --git a/contrib/byacc/test/btyacc/err_syntax11.tab.c b/contrib/byacc/test/btyacc/err_syntax11.tab.c new file mode 100644 index 000000000..dfd0e9a4d --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax11.tab.c @@ -0,0 +1,1259 @@ +/* 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 err_syntax11_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax11_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax11_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax11_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax11_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax11_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax11_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax11_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax11_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax11_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax11_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax11_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos err_syntax11_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto err_syntax11_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax11_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax11_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax11_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax11_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax11_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax11_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax11_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex err_syntax11_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable err_syntax11_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "err_syntax11_" + +#define YYPURE 0 + +#line 2 "err_syntax11.y" +int yylex(void); +static void yyerror(const char *); +#line 124 "err_syntax11.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 YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax11_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax11_len[] = { 2, + 1, +}; +static const YYINT err_syntax11_defred[] = { 0, + 1, 0, +}; +static const YYINT err_syntax11_stos[] = { 0, + 256, 258, +}; +static const YYINT err_syntax11_dgoto[] = { 2, +}; +static const YYINT err_syntax11_sindex[] = { -256, + 0, 0, +}; +static const YYINT err_syntax11_rindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT err_syntax11_cindex[] = { 0, + 0, 0, +}; +#endif +static const YYINT err_syntax11_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT err_syntax11_table[] = { 1, +}; +static const YYINT err_syntax11_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax11_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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", +}; +static const char *const err_syntax11_rule[] = { +"$accept : S", +"S : error", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 12 "err_syntax11.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 369 "err_syntax11.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/err_syntax11.tab.h b/contrib/byacc/test/btyacc/err_syntax11.tab.h new file mode 100644 index 000000000..bfe5d07a7 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax11.tab.h @@ -0,0 +1,5 @@ +#ifndef _err_syntax11__defines_h_ +#define _err_syntax11__defines_h_ + + +#endif /* _err_syntax11__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_syntax12.error b/contrib/byacc/test/btyacc/err_syntax12.error new file mode 100644 index 000000000..9399e82e1 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax12.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./test/err_syntax12.y", the value of text has been redeclared diff --git a/contrib/byacc/test/btyacc/err_syntax12.output b/contrib/byacc/test/btyacc/err_syntax12.output new file mode 100644 index 000000000..6e792d6df --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax12.output @@ -0,0 +1,35 @@ + 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 + + +3 terminals, 2 nonterminals +2 grammar rules, 3 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 456 text + 3 457 $accept + 4 458 S diff --git a/contrib/byacc/test/btyacc/err_syntax12.tab.c b/contrib/byacc/test/btyacc/err_syntax12.tab.c new file mode 100644 index 000000000..86c01c254 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax12.tab.c @@ -0,0 +1,1265 @@ +/* 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 err_syntax12_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax12_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax12_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax12_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax12_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax12_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax12_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax12_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax12_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax12_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax12_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax12_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos err_syntax12_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto err_syntax12_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax12_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax12_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax12_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax12_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax12_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax12_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax12_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex err_syntax12_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable err_syntax12_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "err_syntax12_" + +#define YYPURE 0 + +#line 2 "err_syntax12.y" +int yylex(void); +static void yyerror(const char *); +#line 124 "err_syntax12.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 text 456 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax12_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax12_len[] = { 2, + 1, +}; +static const YYINT err_syntax12_defred[] = { 0, + 1, 0, +}; +static const YYINT err_syntax12_stos[] = { 0, + 256, 458, +}; +static const YYINT err_syntax12_dgoto[] = { 2, +}; +static const YYINT err_syntax12_sindex[] = { -256, + 0, 0, +}; +static const YYINT err_syntax12_rindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT err_syntax12_cindex[] = { 0, + 0, 0, +}; +#endif +static const YYINT err_syntax12_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT err_syntax12_table[] = { 1, +}; +static const YYINT err_syntax12_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 456 +#define YYUNDFTOKEN 459 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax12_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"text","$accept","S", +"illegal-symbol", +}; +static const char *const err_syntax12_rule[] = { +"$accept : S", +"S : error", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 12 "err_syntax12.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 375 "err_syntax12.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/err_syntax12.tab.h b/contrib/byacc/test/btyacc/err_syntax12.tab.h new file mode 100644 index 000000000..6fda3d1e9 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax12.tab.h @@ -0,0 +1,6 @@ +#ifndef _err_syntax12__defines_h_ +#define _err_syntax12__defines_h_ + +#define text 456 + +#endif /* _err_syntax12__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_syntax13.error b/contrib/byacc/test/btyacc/err_syntax13.error new file mode 100644 index 000000000..dd062569c --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax13.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./test/err_syntax13.y", the start symbol text is a token diff --git a/contrib/byacc/test/btyacc/err_syntax13.output b/contrib/byacc/test/btyacc/err_syntax13.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax13.tab.c b/contrib/byacc/test/btyacc/err_syntax13.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax13.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax13.tab.h b/contrib/byacc/test/btyacc/err_syntax13.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax14.error b/contrib/byacc/test/btyacc/err_syntax14.error new file mode 100644 index 000000000..787a21760 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax14.error @@ -0,0 +1,2 @@ +YACC: w - line 7 of "./test/err_syntax14.y", the start symbol has been redeclared +YACC: e - the start symbol text2 is undefined diff --git a/contrib/byacc/test/btyacc/err_syntax14.output b/contrib/byacc/test/btyacc/err_syntax14.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax14.tab.c b/contrib/byacc/test/btyacc/err_syntax14.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax14.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax14.tab.h b/contrib/byacc/test/btyacc/err_syntax14.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax15.error b/contrib/byacc/test/btyacc/err_syntax15.error new file mode 100644 index 000000000..63600f1bd --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax15.error @@ -0,0 +1 @@ +YACC: e - line 9 of "./test/err_syntax15.y", no grammar has been specified diff --git a/contrib/byacc/test/btyacc/err_syntax15.output b/contrib/byacc/test/btyacc/err_syntax15.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax15.tab.c b/contrib/byacc/test/btyacc/err_syntax15.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax15.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax15.tab.h b/contrib/byacc/test/btyacc/err_syntax15.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax16.error b/contrib/byacc/test/btyacc/err_syntax16.error new file mode 100644 index 000000000..b8dd094b9 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax16.error @@ -0,0 +1 @@ +YACC: e - line 14 of "./test/err_syntax16.y", a token appears on the lhs of a production diff --git a/contrib/byacc/test/btyacc/err_syntax16.output b/contrib/byacc/test/btyacc/err_syntax16.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax16.tab.c b/contrib/byacc/test/btyacc/err_syntax16.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax16.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax16.tab.h b/contrib/byacc/test/btyacc/err_syntax16.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax17.error b/contrib/byacc/test/btyacc/err_syntax17.error new file mode 100644 index 000000000..24032f613 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax17.error @@ -0,0 +1,3 @@ +YACC: e - line 8 of "./test/err_syntax17.y", unterminated action +S: { error + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax17.output b/contrib/byacc/test/btyacc/err_syntax17.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax17.tab.c b/contrib/byacc/test/btyacc/err_syntax17.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax17.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax17.tab.h b/contrib/byacc/test/btyacc/err_syntax17.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax18.error b/contrib/byacc/test/btyacc/err_syntax18.error new file mode 100644 index 000000000..305b4cf45 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax18.error @@ -0,0 +1 @@ +YACC: w - line 9 of "./test/err_syntax18.y", $4 references beyond the end of the current rule diff --git a/contrib/byacc/test/btyacc/err_syntax18.output b/contrib/byacc/test/btyacc/err_syntax18.output new file mode 100644 index 000000000..216fb71b6 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax18.output @@ -0,0 +1,52 @@ + 0 $accept : expr $end + + 1 expr : '(' expr ')' + +state 0 + $accept : . expr $end (0) + + '(' shift 1 + . error + + expr goto 2 + + +state 1 + expr : '(' . expr ')' (1) + + '(' shift 1 + . error + + expr goto 3 + + +state 2 + $accept : expr . $end (0) + + $end accept + + +state 3 + expr : '(' expr . ')' (1) + + ')' shift 4 + . error + + +state 4 + expr : '(' expr ')' . (1) + + . reduce 1 + + +4 terminals, 2 nonterminals +2 grammar rules, 5 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 40 '(' + 3 41 ')' + 4 257 $accept + 5 258 expr diff --git a/contrib/byacc/test/btyacc/err_syntax18.tab.c b/contrib/byacc/test/btyacc/err_syntax18.tab.c new file mode 100644 index 000000000..2a8a10948 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax18.tab.c @@ -0,0 +1,1266 @@ +/* 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 err_syntax18_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax18_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax18_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax18_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax18_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax18_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax18_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax18_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax18_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax18_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax18_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax18_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos err_syntax18_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto err_syntax18_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax18_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax18_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax18_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax18_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax18_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax18_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax18_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex err_syntax18_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable err_syntax18_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "err_syntax18_" + +#define YYPURE 0 + +#line 2 "err_syntax18.y" +int yylex(void); +static void yyerror(const char *); +#line 124 "err_syntax18.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 YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax18_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax18_len[] = { 2, + 3, +}; +static const YYINT err_syntax18_defred[] = { 0, + 0, 0, 0, 1, +}; +static const YYINT err_syntax18_stos[] = { 0, + 40, 258, 258, 41, +}; +static const YYINT err_syntax18_dgoto[] = { 2, +}; +static const YYINT err_syntax18_sindex[] = { -40, + -40, 0, -39, 0, +}; +static const YYINT err_syntax18_rindex[] = { 0, + 0, 0, 0, 0, +}; +#if YYBTYACC +static const YYINT err_syntax18_cindex[] = { 0, + 0, 0, 0, 0, +}; +#endif +static const YYINT err_syntax18_gindex[] = { 2, +}; +#define YYTABLESIZE 3 +static const YYINT err_syntax18_table[] = { 1, + 0, 4, 3, +}; +static const YYINT err_syntax18_check[] = { 40, + -1, 41, 1, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax18_name[] = { + +"$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, +0,0,0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","expr", +"illegal-symbol", +}; +static const char *const err_syntax18_rule[] = { +"$accept : expr", +"expr : '(' expr ')'", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 13 "err_syntax18.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 371 "err_syntax18.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 9 "err_syntax18.y" + { yyval = yystack.l_mark[1]; } +break; +#line 1032 "err_syntax18.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/err_syntax18.tab.h b/contrib/byacc/test/btyacc/err_syntax18.tab.h new file mode 100644 index 000000000..f08352a9b --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax18.tab.h @@ -0,0 +1,5 @@ +#ifndef _err_syntax18__defines_h_ +#define _err_syntax18__defines_h_ + + +#endif /* _err_syntax18__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_syntax19.error b/contrib/byacc/test/btyacc/err_syntax19.error new file mode 100644 index 000000000..895c8fe16 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax19.error @@ -0,0 +1,3 @@ +YACC: e - line 9 of "./test/err_syntax19.y", illegal $-name + { $$ = $; } + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax19.output b/contrib/byacc/test/btyacc/err_syntax19.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax19.tab.c b/contrib/byacc/test/btyacc/err_syntax19.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax19.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax19.tab.h b/contrib/byacc/test/btyacc/err_syntax19.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax2.error b/contrib/byacc/test/btyacc/err_syntax2.error new file mode 100644 index 000000000..fefda9fcf --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax2.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./test/err_syntax2.y", unmatched /* +%{ /* + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax2.output b/contrib/byacc/test/btyacc/err_syntax2.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax2.tab.c b/contrib/byacc/test/btyacc/err_syntax2.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax2.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax2.tab.h b/contrib/byacc/test/btyacc/err_syntax2.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax20.error b/contrib/byacc/test/btyacc/err_syntax20.error new file mode 100644 index 000000000..76dac8152 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax20.error @@ -0,0 +1 @@ +YACC: w - the symbol recur is undefined diff --git a/contrib/byacc/test/btyacc/err_syntax20.output b/contrib/byacc/test/btyacc/err_syntax20.output new file mode 100644 index 000000000..f0378d42e --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax20.output @@ -0,0 +1,51 @@ + 0 $accept : expr $end + + 1 expr : '(' recur ')' + +state 0 + $accept : . expr $end (0) + + '(' shift 1 + . error + + expr goto 2 + + +state 1 + expr : '(' . recur ')' (1) + + recur shift 3 + . error + + +state 2 + $accept : expr . $end (0) + + $end accept + + +state 3 + expr : '(' recur . ')' (1) + + ')' shift 4 + . error + + +state 4 + expr : '(' recur ')' . (1) + + . reduce 1 + + +5 terminals, 2 nonterminals +2 grammar rules, 5 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 recur + 3 40 '(' + 4 41 ')' + 5 258 $accept + 6 259 expr diff --git a/contrib/byacc/test/btyacc/err_syntax20.tab.c b/contrib/byacc/test/btyacc/err_syntax20.tab.c new file mode 100644 index 000000000..80ec2ed82 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax20.tab.c @@ -0,0 +1,1261 @@ +/* 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 err_syntax20_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax20_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax20_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax20_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax20_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax20_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax20_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax20_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax20_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax20_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax20_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax20_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos err_syntax20_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto err_syntax20_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax20_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax20_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax20_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax20_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax20_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax20_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax20_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex err_syntax20_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable err_syntax20_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "err_syntax20_" + +#define YYPURE 0 + +#line 2 "err_syntax20.y" +int yylex(void); +static void yyerror(const char *); +#line 124 "err_syntax20.tab.c" + +/* 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 recur 257 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax20_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax20_len[] = { 2, + 3, +}; +static const YYINT err_syntax20_defred[] = { 0, + 0, 0, 0, 1, +}; +static const YYINT err_syntax20_stos[] = { 0, + 40, 259, 257, 41, +}; +static const YYINT err_syntax20_dgoto[] = { 2, +}; +static const YYINT err_syntax20_sindex[] = { -40, + -256, 0, -39, 0, +}; +static const YYINT err_syntax20_rindex[] = { 0, + 0, 0, 0, 0, +}; +#if YYBTYACC +static const YYINT err_syntax20_cindex[] = { 0, + 0, 0, 0, 0, +}; +#endif +static const YYINT err_syntax20_gindex[] = { 0, +}; +#define YYTABLESIZE 2 +static const YYINT err_syntax20_table[] = { 1, + 3, 4, +}; +static const YYINT err_syntax20_check[] = { 40, + 257, 41, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 257 +#define YYUNDFTOKEN 260 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax20_name[] = { + +"$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, +0,0,0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","recur","$accept","expr", +"illegal-symbol", +}; +static const char *const err_syntax20_rule[] = { +"$accept : expr", +"expr : '(' recur ')'", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 16 "err_syntax20.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 366 "err_syntax20.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 12 "err_syntax20.y" + { yystack.l_mark[-1].rechk = 3; } +break; +#line 1027 "err_syntax20.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/err_syntax20.tab.h b/contrib/byacc/test/btyacc/err_syntax20.tab.h new file mode 100644 index 000000000..fb019706f --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax20.tab.h @@ -0,0 +1,6 @@ +#ifndef _err_syntax20__defines_h_ +#define _err_syntax20__defines_h_ + +#define recur 257 + +#endif /* _err_syntax20__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_syntax21.error b/contrib/byacc/test/btyacc/err_syntax21.error new file mode 100644 index 000000000..162d82d0c --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax21.error @@ -0,0 +1 @@ +YACC: e - line 12 of "./test/err_syntax21.y", $0 is untyped diff --git a/contrib/byacc/test/btyacc/err_syntax21.output b/contrib/byacc/test/btyacc/err_syntax21.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax21.tab.c b/contrib/byacc/test/btyacc/err_syntax21.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax21.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax21.tab.h b/contrib/byacc/test/btyacc/err_syntax21.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax22.error b/contrib/byacc/test/btyacc/err_syntax22.error new file mode 100644 index 000000000..9c71619c4 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax22.error @@ -0,0 +1 @@ +YACC: e - line 17 of "./test/err_syntax22.y", $2 (recur) is untyped diff --git a/contrib/byacc/test/btyacc/err_syntax22.output b/contrib/byacc/test/btyacc/err_syntax22.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax22.tab.c b/contrib/byacc/test/btyacc/err_syntax22.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax22.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax22.tab.h b/contrib/byacc/test/btyacc/err_syntax22.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax23.error b/contrib/byacc/test/btyacc/err_syntax23.error new file mode 100644 index 000000000..bcde6e7fa --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax23.error @@ -0,0 +1 @@ +YACC: e - line 18 of "./test/err_syntax23.y", $$ is untyped diff --git a/contrib/byacc/test/btyacc/err_syntax23.output b/contrib/byacc/test/btyacc/err_syntax23.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax23.tab.c b/contrib/byacc/test/btyacc/err_syntax23.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax23.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax23.tab.h b/contrib/byacc/test/btyacc/err_syntax23.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax24.error b/contrib/byacc/test/btyacc/err_syntax24.error new file mode 100644 index 000000000..bdd3aeda0 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax24.error @@ -0,0 +1,2 @@ +YACC: w - line 21 of "./test/err_syntax24.y", the default action assigns an undefined value to $$ +YACC: e - line 22 of "./test/err_syntax24.y", $$ is untyped diff --git a/contrib/byacc/test/btyacc/err_syntax24.output b/contrib/byacc/test/btyacc/err_syntax24.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax24.tab.c b/contrib/byacc/test/btyacc/err_syntax24.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax24.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax24.tab.h b/contrib/byacc/test/btyacc/err_syntax24.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax25.error b/contrib/byacc/test/btyacc/err_syntax25.error new file mode 100644 index 000000000..ea45a7031 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax25.error @@ -0,0 +1,3 @@ +YACC: e - line 11 of "./test/err_syntax25.y", too many %union declarations +%union { +^ diff --git a/contrib/byacc/test/btyacc/err_syntax25.output b/contrib/byacc/test/btyacc/err_syntax25.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax25.tab.c b/contrib/byacc/test/btyacc/err_syntax25.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax25.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax25.tab.h b/contrib/byacc/test/btyacc/err_syntax25.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax26.error b/contrib/byacc/test/btyacc/err_syntax26.error new file mode 100644 index 000000000..cddd5741b --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax26.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./test/err_syntax26.y", unexpected end-of-file diff --git a/contrib/byacc/test/btyacc/err_syntax26.output b/contrib/byacc/test/btyacc/err_syntax26.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax26.tab.c b/contrib/byacc/test/btyacc/err_syntax26.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax26.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax26.tab.h b/contrib/byacc/test/btyacc/err_syntax26.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax27.error b/contrib/byacc/test/btyacc/err_syntax27.error new file mode 100644 index 000000000..4737f99b9 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax27.error @@ -0,0 +1 @@ +YACC: e - line 3 of "./test/err_syntax27.y", missing '}' diff --git a/contrib/byacc/test/btyacc/err_syntax27.output b/contrib/byacc/test/btyacc/err_syntax27.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax27.tab.c b/contrib/byacc/test/btyacc/err_syntax27.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax27.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax27.tab.h b/contrib/byacc/test/btyacc/err_syntax27.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax3.error b/contrib/byacc/test/btyacc/err_syntax3.error new file mode 100644 index 000000000..6926214f5 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax3.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax3.y", unterminated string +%token '(' '*' '& + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax3.output b/contrib/byacc/test/btyacc/err_syntax3.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax3.tab.c b/contrib/byacc/test/btyacc/err_syntax3.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax3.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax3.tab.h b/contrib/byacc/test/btyacc/err_syntax3.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax4.error b/contrib/byacc/test/btyacc/err_syntax4.error new file mode 100644 index 000000000..72b683ee7 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax4.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./test/err_syntax4.y", unmatched %{ +%{ +^ diff --git a/contrib/byacc/test/btyacc/err_syntax4.output b/contrib/byacc/test/btyacc/err_syntax4.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax4.tab.c b/contrib/byacc/test/btyacc/err_syntax4.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax4.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax4.tab.h b/contrib/byacc/test/btyacc/err_syntax4.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax5.error b/contrib/byacc/test/btyacc/err_syntax5.error new file mode 100644 index 000000000..fd3bf0df6 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax5.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax5.y", unterminated %union declaration +%union { +^ diff --git a/contrib/byacc/test/btyacc/err_syntax5.output b/contrib/byacc/test/btyacc/err_syntax5.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax5.tab.c b/contrib/byacc/test/btyacc/err_syntax5.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax5.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax5.tab.h b/contrib/byacc/test/btyacc/err_syntax5.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax6.error b/contrib/byacc/test/btyacc/err_syntax6.error new file mode 100644 index 000000000..ae83bd2a3 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax6.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax6.y", illegal tag +%token '\777' + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax7.output b/contrib/byacc/test/btyacc/err_syntax7.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax7.tab.c b/contrib/byacc/test/btyacc/err_syntax7.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax7.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax7.tab.h b/contrib/byacc/test/btyacc/err_syntax7.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax7a.error b/contrib/byacc/test/btyacc/err_syntax7a.error new file mode 100644 index 000000000..f6adba64d --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax7a.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax7a.y", illegal character +%token '\xfff' + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax7a.output b/contrib/byacc/test/btyacc/err_syntax7a.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax7a.tab.c b/contrib/byacc/test/btyacc/err_syntax7a.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax7a.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax7a.tab.h b/contrib/byacc/test/btyacc/err_syntax7a.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax7b.error b/contrib/byacc/test/btyacc/err_syntax7b.error new file mode 100644 index 000000000..f3e512fd1 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax7b.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax7b.y", illegal character +%token '\x.' + ^ diff --git a/contrib/byacc/test/btyacc/err_syntax7b.output b/contrib/byacc/test/btyacc/err_syntax7b.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax7b.tab.c b/contrib/byacc/test/btyacc/err_syntax7b.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax7b.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax7b.tab.h b/contrib/byacc/test/btyacc/err_syntax7b.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax8.error b/contrib/byacc/test/btyacc/err_syntax8.error new file mode 100644 index 000000000..53a3a328d --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax8.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./test/err_syntax8.y", illegal use of reserved symbol . diff --git a/contrib/byacc/test/btyacc/err_syntax8.output b/contrib/byacc/test/btyacc/err_syntax8.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax8.tab.c b/contrib/byacc/test/btyacc/err_syntax8.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax8.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax8.tab.h b/contrib/byacc/test/btyacc/err_syntax8.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax8a.error b/contrib/byacc/test/btyacc/err_syntax8a.error new file mode 100644 index 000000000..313555163 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax8a.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./test/err_syntax8a.y", illegal use of reserved symbol $$123 diff --git a/contrib/byacc/test/btyacc/err_syntax8a.output b/contrib/byacc/test/btyacc/err_syntax8a.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax8a.tab.c b/contrib/byacc/test/btyacc/err_syntax8a.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax8a.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax8a.tab.h b/contrib/byacc/test/btyacc/err_syntax8a.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax9.error b/contrib/byacc/test/btyacc/err_syntax9.error new file mode 100644 index 000000000..43696bd1f --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax9.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./test/err_syntax9.y", the start symbol text cannot be declared to be a token diff --git a/contrib/byacc/test/btyacc/err_syntax9.output b/contrib/byacc/test/btyacc/err_syntax9.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/err_syntax9.tab.c b/contrib/byacc/test/btyacc/err_syntax9.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/btyacc/err_syntax9.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/btyacc/err_syntax9.tab.h b/contrib/byacc/test/btyacc/err_syntax9.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/error.error b/contrib/byacc/test/btyacc/error.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/error.output b/contrib/byacc/test/btyacc/error.output new file mode 100644 index 000000000..1e56c214a --- /dev/null +++ b/contrib/byacc/test/btyacc/error.output @@ -0,0 +1,34 @@ + 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/contrib/byacc/test/btyacc/error.tab.c b/contrib/byacc/test/btyacc/error.tab.c new file mode 100644 index 000000000..17cd75cad --- /dev/null +++ b/contrib/byacc/test/btyacc/error.tab.c @@ -0,0 +1,1258 @@ +/* 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 error_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex error_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror error_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar error_char +#endif /* yychar */ + +#ifndef yyval +#define yyval error_val +#endif /* yyval */ + +#ifndef yylval +#define yylval error_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug error_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs error_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag error_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs error_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen error_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred error_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos error_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto error_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex error_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex error_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex error_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable error_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck error_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname error_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule error_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex error_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable error_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "error_" + +#define YYPURE 0 + +#line 2 "error.y" +int yylex(void); +static void yyerror(const char *); +#line 124 "error.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 YYERRCODE 256 +typedef short YYINT; +static const YYINT error_lhs[] = { -1, + 0, +}; +static const YYINT error_len[] = { 2, + 1, +}; +static const YYINT error_defred[] = { 0, + 1, 0, +}; +static const YYINT error_stos[] = { 0, + 256, 258, +}; +static const YYINT error_dgoto[] = { 2, +}; +static const YYINT error_sindex[] = { -256, + 0, 0, +}; +static const YYINT error_rindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT error_cindex[] = { 0, + 0, 0, +}; +#endif +static const YYINT error_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT error_table[] = { 1, +}; +static const YYINT error_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const error_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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", +}; +static const char *const error_rule[] = { +"$accept : S", +"S : error", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 8 "error.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 368 "error.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/error.tab.h b/contrib/byacc/test/btyacc/error.tab.h new file mode 100644 index 000000000..f9e5ad278 --- /dev/null +++ b/contrib/byacc/test/btyacc/error.tab.h @@ -0,0 +1,5 @@ +#ifndef _error__defines_h_ +#define _error__defines_h_ + + +#endif /* _error__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/grammar.dot b/contrib/byacc/test/btyacc/grammar.dot new file mode 100644 index 000000000..1988e12dd --- /dev/null +++ b/contrib/byacc/test/btyacc/grammar.dot @@ -0,0 +1,906 @@ +digraph test-grammar { + edge [fontsize=10]; + node [shape=box,fontsize=10]; + orientation=landscape; + rankdir=LR; + /* + margin=0.2; + page="8.27,11.69"; // for A4 printing + ratio=auto; + */ + + q0 [label="0:\l $accept -> . program $end\l program -> . { $end }\l program -> . translation_unit\l translation_unit -> . external_declaration\l translation_unit -> . translation_unit external_declaration\l external_declaration -> . declaration\l external_declaration -> . function_definition\l external_declaration -> . ';'\l external_declaration -> . linkage_specification\l external_declaration -> . T_ASM T_ASMARG ';'\l external_declaration -> . error T_MATCHRBRACE\l external_declaration -> . error ';'\l linkage_specification -> . T_EXTERN T_STRING_LITERAL braces\l linkage_specification -> . T_EXTERN T_STRING_LITERAL declaration\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> . decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l function_definition -> . declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q1 [label="1:\l external_declaration -> error . T_MATCHRBRACE\l external_declaration -> error . ';'\l"]; + q2 [label="2:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> '(' . declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q3 [label="3:\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l pointer -> '*' . opt_type_qualifiers\l pointer -> '*' . opt_type_qualifiers pointer\l opt_type_qualifiers -> . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l opt_type_qualifiers -> . type_qualifier_list\l type_qualifier_list -> . type_qualifier\l type_qualifier_list -> . type_qualifier_list type_qualifier\l"]; + q4 [label="4:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l identifier_or_ref -> '&' . any_id\l"]; + q5 [label="5:\l any_id -> T_IDENTIFIER . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q6 [label="6:\l type_specifier -> T_TYPEDEF_NAME . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l any_id -> T_TYPEDEF_NAME . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q7 [label="7:\l type_qualifier -> T_DEFINE_NAME . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q8 [label="8:\l storage_class -> T_AUTO . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q9 [label="9:\l linkage_specification -> T_EXTERN . T_STRING_LITERAL braces\l linkage_specification -> T_EXTERN . T_STRING_LITERAL declaration\l storage_class -> T_EXTERN . { ';' T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q10 [label="10:\l storage_class -> T_REGISTER . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q11 [label="11:\l storage_class -> T_STATIC . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q12 [label="12:\l any_typedef -> T_TYPEDEF . { T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q13 [label="13:\l storage_class -> T_INLINE . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q14 [label="14:\l any_typedef -> T_EXTENSION . T_TYPEDEF\l storage_class -> T_EXTENSION . { ';' T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q15 [label="15:\l type_specifier -> T_CHAR . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q16 [label="16:\l type_specifier -> T_DOUBLE . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q17 [label="17:\l type_specifier -> T_FLOAT . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q18 [label="18:\l type_specifier -> T_INT . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q19 [label="19:\l type_specifier -> T_VOID . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q20 [label="20:\l type_specifier -> T_LONG . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q21 [label="21:\l type_specifier -> T_SHORT . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q22 [label="22:\l type_specifier -> T_SIGNED . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q23 [label="23:\l type_specifier -> T_UNSIGNED . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q24 [label="24:\l enumeration -> T_ENUM . { T_LBRACE T_TYPEDEF_NAME T_IDENTIFIER }\l"]; + q25 [label="25:\l struct_or_union -> T_STRUCT . { T_LBRACE T_TYPEDEF_NAME T_IDENTIFIER }\l"]; + q26 [label="26:\l struct_or_union -> T_UNION . { T_LBRACE T_TYPEDEF_NAME T_IDENTIFIER }\l"]; + q27 [label="27:\l type_specifier -> T_Bool . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q28 [label="28:\l type_specifier -> T_Complex . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q29 [label="29:\l type_specifier -> T_Imaginary . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q30 [label="30:\l type_qualifier -> T_TYPE_QUALIFIER . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q31 [label="31:\l external_declaration -> T_ASM . T_ASMARG ';'\l"]; + q32 [label="32:\l external_declaration -> ';' . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q33 [label="33:\l $accept -> program . $end\l"]; + q34 [label="34:\l declaration -> decl_specifiers . ';'\l declaration -> decl_specifiers . init_declarator_list ';'\l function_definition -> decl_specifiers . declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l init_declarator_list -> . init_declarator\l init_declarator_list -> . init_declarator_list ',' init_declarator\l init_declarator -> . declarator\l init_declarator -> . declarator '=' $$5 T_INITIALIZER\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q35 [label="35:\l decl_specifiers -> decl_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q36 [label="36:\l decl_specifier -> storage_class . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q37 [label="37:\l decl_specifier -> type_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q38 [label="38:\l decl_specifier -> type_qualifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q39 [label="39:\l type_specifier -> struct_or_union_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q40 [label="40:\l type_specifier -> enum_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q41 [label="41:\l $$4 -> . { T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l function_definition -> declarator . $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE\l"]; + q42 [label="42:\l declarator -> direct_declarator . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l direct_declarator -> direct_declarator . T_BRACKETS\l direct_declarator -> direct_declarator . '(' parameter_type_list ')'\l direct_declarator -> direct_declarator . '(' opt_identifier_list ')'\l"]; + q43 [label="43:\l braces -> . T_LBRACE T_MATCHRBRACE\l struct_or_union_specifier -> struct_or_union . any_id braces\l struct_or_union_specifier -> struct_or_union . braces\l struct_or_union_specifier -> struct_or_union . any_id\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l"]; + q44 [label="44:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> pointer . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q45 [label="45:\l identifier_or_ref -> any_id . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q46 [label="46:\l direct_declarator -> identifier_or_ref . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q47 [label="47:\l braces -> . T_LBRACE T_MATCHRBRACE\l enum_specifier -> enumeration . any_id braces\l enum_specifier -> enumeration . braces\l enum_specifier -> enumeration . any_id\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l"]; + q48 [label="48:\l program -> translation_unit . { $end }\l translation_unit -> translation_unit . external_declaration\l external_declaration -> . declaration\l external_declaration -> . function_definition\l external_declaration -> . ';'\l external_declaration -> . linkage_specification\l external_declaration -> . T_ASM T_ASMARG ';'\l external_declaration -> . error T_MATCHRBRACE\l external_declaration -> . error ';'\l linkage_specification -> . T_EXTERN T_STRING_LITERAL braces\l linkage_specification -> . T_EXTERN T_STRING_LITERAL declaration\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> . decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l function_definition -> . declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q49 [label="49:\l translation_unit -> external_declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q50 [label="50:\l external_declaration -> declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q51 [label="51:\l external_declaration -> function_definition . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q52 [label="52:\l external_declaration -> linkage_specification . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q53 [label="53:\l declaration -> any_typedef . decl_specifiers $$1 opt_declarator_list ';'\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q54 [label="54:\l external_declaration -> error T_MATCHRBRACE . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q55 [label="55:\l external_declaration -> error ';' . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q56 [label="56:\l any_id -> T_TYPEDEF_NAME . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q57 [label="57:\l direct_declarator -> '(' declarator . ')'\l"]; + q58 [label="58:\l type_qualifier_list -> type_qualifier . { ')' ',' T_BRACKETS T_TYPE_QUALIFIER T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q59 [label="59:\l pointer -> . '*' opt_type_qualifiers\l pointer -> '*' opt_type_qualifiers . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '(' }\l pointer -> . '*' opt_type_qualifiers pointer\l pointer -> '*' opt_type_qualifiers . pointer\l"]; + q60 [label="60:\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l opt_type_qualifiers -> type_qualifier_list . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l type_qualifier_list -> type_qualifier_list . type_qualifier\l"]; + q61 [label="61:\l identifier_or_ref -> '&' any_id . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q62 [label="62:\l braces -> . T_LBRACE T_MATCHRBRACE\l linkage_specification -> T_EXTERN T_STRING_LITERAL . braces\l linkage_specification -> T_EXTERN T_STRING_LITERAL . declaration\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q63 [label="63:\l any_typedef -> T_EXTENSION T_TYPEDEF . { T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q64 [label="64:\l external_declaration -> T_ASM T_ASMARG . ';'\l"]; + q65 [label="65:\l storage_class -> T_EXTERN . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q66 [label="66:\l storage_class -> T_EXTENSION . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q67 [label="67:\l declaration -> decl_specifiers ';' . { ';' T_ASM T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q68 [label="68:\l decl_specifiers -> decl_specifiers decl_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q69 [label="69:\l declaration -> decl_specifiers init_declarator_list . ';'\l init_declarator_list -> init_declarator_list . ',' init_declarator\l"]; + q70 [label="70:\l init_declarator_list -> init_declarator . { ',' ';' }\l"]; + q71 [label="71:\l $$2 -> . { T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l function_definition -> decl_specifiers declarator . $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l init_declarator -> declarator . { ',' ';' }\l init_declarator -> declarator . '=' $$5 T_INITIALIZER\l"]; + q72 [label="72:\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> declarator $$4 . opt_declaration_list T_LBRACE T_MATCHRBRACE\l opt_declaration_list -> . { T_LBRACE }\l opt_declaration_list -> . T_VA_DCL\l opt_declaration_list -> . declaration_list\l declaration_list -> . declaration\l declaration_list -> . declaration_list declaration\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q73 [label="73:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l direct_declarator -> direct_declarator '(' . parameter_type_list ')'\l direct_declarator -> direct_declarator '(' . opt_identifier_list ')'\l parameter_type_list -> . parameter_list\l parameter_type_list -> . parameter_list ',' T_ELLIPSIS\l parameter_list -> . parameter_declaration\l parameter_list -> . parameter_list ',' parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l opt_identifier_list -> . { ')' }\l opt_identifier_list -> . identifier_list\l identifier_list -> . any_id\l identifier_list -> . identifier_list ',' any_id\l"]; + q74 [label="74:\l direct_declarator -> direct_declarator T_BRACKETS . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q75 [label="75:\l braces -> T_LBRACE . T_MATCHRBRACE\l"]; + q76 [label="76:\l braces -> . T_LBRACE T_MATCHRBRACE\l struct_or_union_specifier -> struct_or_union any_id . braces\l struct_or_union_specifier -> struct_or_union any_id . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q77 [label="77:\l struct_or_union_specifier -> struct_or_union braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q78 [label="78:\l declarator -> pointer direct_declarator . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l direct_declarator -> direct_declarator . T_BRACKETS\l direct_declarator -> direct_declarator . '(' parameter_type_list ')'\l direct_declarator -> direct_declarator . '(' opt_identifier_list ')'\l"]; + q79 [label="79:\l braces -> . T_LBRACE T_MATCHRBRACE\l enum_specifier -> enumeration any_id . braces\l enum_specifier -> enumeration any_id . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q80 [label="80:\l enum_specifier -> enumeration braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q81 [label="81:\l translation_unit -> translation_unit external_declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q82 [label="82:\l type_specifier -> T_TYPEDEF_NAME . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q83 [label="83:\l $$1 -> . { ';' T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l declaration -> any_typedef decl_specifiers . $$1 opt_declarator_list ';'\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q84 [label="84:\l direct_declarator -> '(' declarator ')' . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q85 [label="85:\l pointer -> '*' opt_type_qualifiers pointer . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '(' }\l"]; + q86 [label="86:\l type_qualifier_list -> type_qualifier_list type_qualifier . { ')' ',' T_BRACKETS T_TYPE_QUALIFIER T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q87 [label="87:\l declaration -> decl_specifiers . ';'\l declaration -> decl_specifiers . init_declarator_list ';'\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l init_declarator_list -> . init_declarator\l init_declarator_list -> . init_declarator_list ',' init_declarator\l init_declarator -> . declarator\l init_declarator -> . declarator '=' $$5 T_INITIALIZER\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q88 [label="88:\l linkage_specification -> T_EXTERN T_STRING_LITERAL declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q89 [label="89:\l linkage_specification -> T_EXTERN T_STRING_LITERAL braces . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q90 [label="90:\l external_declaration -> T_ASM T_ASMARG ';' . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q91 [label="91:\l declaration -> decl_specifiers init_declarator_list ';' . { ';' T_ASM T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q92 [label="92:\l init_declarator_list -> init_declarator_list ',' . init_declarator\l init_declarator -> . declarator\l init_declarator -> . declarator '=' $$5 T_INITIALIZER\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q93 [label="93:\l $$5 -> . { T_INITIALIZER }\l init_declarator -> declarator '=' . $$5 T_INITIALIZER\l"]; + q94 [label="94:\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> decl_specifiers declarator $$2 . opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l opt_declaration_list -> . { T_LBRACE }\l opt_declaration_list -> . T_VA_DCL\l opt_declaration_list -> . declaration_list\l declaration_list -> . declaration\l declaration_list -> . declaration_list declaration\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q95 [label="95:\l opt_declaration_list -> T_VA_DCL . { T_LBRACE }\l"]; + q96 [label="96:\l declaration_list -> declaration . { T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q97 [label="97:\l function_definition -> declarator $$4 opt_declaration_list . T_LBRACE T_MATCHRBRACE\l"]; + q98 [label="98:\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l opt_declaration_list -> declaration_list . { T_LBRACE }\l declaration_list -> declaration_list . declaration\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q99 [label="99:\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l parameter_declaration -> decl_specifiers . declarator\l parameter_declaration -> decl_specifiers . abs_declarator\l parameter_declaration -> decl_specifiers . { ')' ',' }\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l abs_declarator -> . pointer\l abs_declarator -> . pointer direct_abs_declarator\l abs_declarator -> . direct_abs_declarator\l direct_abs_declarator -> . '(' abs_declarator ')'\l direct_abs_declarator -> . direct_abs_declarator T_BRACKETS\l direct_abs_declarator -> . T_BRACKETS\l direct_abs_declarator -> . direct_abs_declarator '(' parameter_type_list ')'\l direct_abs_declarator -> . direct_abs_declarator '(' ')'\l direct_abs_declarator -> . '(' parameter_type_list ')'\l direct_abs_declarator -> . '(' ')'\l"]; + q100 [label="100:\l direct_declarator -> direct_declarator '(' parameter_type_list . ')'\l"]; + q101 [label="101:\l parameter_type_list -> parameter_list . { ')' }\l parameter_type_list -> parameter_list . ',' T_ELLIPSIS\l parameter_list -> parameter_list . ',' parameter_declaration\l"]; + q102 [label="102:\l parameter_list -> parameter_declaration . { ')' ',' }\l"]; + q103 [label="103:\l direct_declarator -> direct_declarator '(' opt_identifier_list . ')'\l"]; + q104 [label="104:\l opt_identifier_list -> identifier_list . { ')' }\l identifier_list -> identifier_list . ',' any_id\l"]; + q105 [label="105:\l identifier_list -> any_id . { ')' ',' }\l"]; + q106 [label="106:\l braces -> T_LBRACE T_MATCHRBRACE . { ')' ',' ';' T_ASM T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q107 [label="107:\l struct_or_union_specifier -> struct_or_union any_id braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q108 [label="108:\l enum_specifier -> enumeration any_id braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q109 [label="109:\l declaration -> any_typedef decl_specifiers $$1 . opt_declarator_list ';'\l opt_declarator_list -> . { ';' }\l opt_declarator_list -> . declarator_list\l declarator_list -> . declarator\l declarator_list -> . declarator_list ',' declarator\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q110 [label="110:\l init_declarator -> declarator . { ',' ';' }\l init_declarator -> declarator . '=' $$5 T_INITIALIZER\l"]; + q111 [label="111:\l init_declarator_list -> init_declarator_list ',' init_declarator . { ',' ';' }\l"]; + q112 [label="112:\l init_declarator -> declarator '=' $$5 . T_INITIALIZER\l"]; + q113 [label="113:\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list . T_LBRACE $$3 T_MATCHRBRACE\l"]; + q114 [label="114:\l function_definition -> declarator $$4 opt_declaration_list T_LBRACE . T_MATCHRBRACE\l"]; + q115 [label="115:\l declaration_list -> declaration_list declaration . { T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q116 [label="116:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> '(' . declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l parameter_type_list -> . parameter_list\l parameter_type_list -> . parameter_list ',' T_ELLIPSIS\l parameter_list -> . parameter_declaration\l parameter_list -> . parameter_list ',' parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l abs_declarator -> . pointer\l abs_declarator -> . pointer direct_abs_declarator\l abs_declarator -> . direct_abs_declarator\l direct_abs_declarator -> . '(' abs_declarator ')'\l direct_abs_declarator -> '(' . abs_declarator ')'\l direct_abs_declarator -> . direct_abs_declarator T_BRACKETS\l direct_abs_declarator -> . T_BRACKETS\l direct_abs_declarator -> . direct_abs_declarator '(' parameter_type_list ')'\l direct_abs_declarator -> . direct_abs_declarator '(' ')'\l direct_abs_declarator -> . '(' parameter_type_list ')'\l direct_abs_declarator -> '(' . parameter_type_list ')'\l direct_abs_declarator -> . '(' ')'\l direct_abs_declarator -> '(' . ')'\l"]; + q117 [label="117:\l direct_abs_declarator -> T_BRACKETS . { ')' ',' T_BRACKETS '(' }\l"]; + q118 [label="118:\l parameter_declaration -> decl_specifiers declarator . { ')' ',' }\l"]; + q119 [label="119:\l parameter_declaration -> decl_specifiers abs_declarator . { ')' ',' }\l"]; + q120 [label="120:\l abs_declarator -> direct_abs_declarator . { ')' ',' }\l direct_abs_declarator -> direct_abs_declarator . T_BRACKETS\l direct_abs_declarator -> direct_abs_declarator . '(' parameter_type_list ')'\l direct_abs_declarator -> direct_abs_declarator . '(' ')'\l"]; + q121 [label="121:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> pointer . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l abs_declarator -> pointer . { ')' ',' }\l abs_declarator -> pointer . direct_abs_declarator\l direct_abs_declarator -> . '(' abs_declarator ')'\l direct_abs_declarator -> . direct_abs_declarator T_BRACKETS\l direct_abs_declarator -> . T_BRACKETS\l direct_abs_declarator -> . direct_abs_declarator '(' parameter_type_list ')'\l direct_abs_declarator -> . direct_abs_declarator '(' ')'\l direct_abs_declarator -> . '(' parameter_type_list ')'\l direct_abs_declarator -> . '(' ')'\l"]; + q122 [label="122:\l direct_declarator -> direct_declarator '(' parameter_type_list ')' . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q123 [label="123:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l parameter_type_list -> parameter_list ',' . T_ELLIPSIS\l parameter_list -> parameter_list ',' . parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l"]; + q124 [label="124:\l direct_declarator -> direct_declarator '(' opt_identifier_list ')' . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q125 [label="125:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l identifier_list -> identifier_list ',' . any_id\l"]; + q126 [label="126:\l declarator_list -> declarator . { ',' ';' }\l"]; + q127 [label="127:\l declaration -> any_typedef decl_specifiers $$1 opt_declarator_list . ';'\l"]; + q128 [label="128:\l opt_declarator_list -> declarator_list . { ';' }\l declarator_list -> declarator_list . ',' declarator\l"]; + q129 [label="129:\l init_declarator -> declarator '=' $$5 T_INITIALIZER . { ',' ';' }\l"]; + q130 [label="130:\l $$3 -> . { T_MATCHRBRACE }\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list T_LBRACE . $$3 T_MATCHRBRACE\l"]; + q131 [label="131:\l function_definition -> declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q132 [label="132:\l direct_abs_declarator -> '(' ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q133 [label="133:\l direct_abs_declarator -> '(' abs_declarator . ')'\l"]; + q134 [label="134:\l direct_abs_declarator -> '(' parameter_type_list . ')'\l"]; + q135 [label="135:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l parameter_type_list -> . parameter_list\l parameter_type_list -> . parameter_list ',' T_ELLIPSIS\l parameter_list -> . parameter_declaration\l parameter_list -> . parameter_list ',' parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l direct_abs_declarator -> direct_abs_declarator '(' . parameter_type_list ')'\l direct_abs_declarator -> direct_abs_declarator '(' . ')'\l"]; + q136 [label="136:\l direct_abs_declarator -> direct_abs_declarator T_BRACKETS . { ')' ',' T_BRACKETS '(' }\l"]; + q137 [label="137:\l abs_declarator -> pointer direct_abs_declarator . { ')' ',' }\l direct_abs_declarator -> direct_abs_declarator . T_BRACKETS\l direct_abs_declarator -> direct_abs_declarator . '(' parameter_type_list ')'\l direct_abs_declarator -> direct_abs_declarator . '(' ')'\l"]; + q138 [label="138:\l parameter_type_list -> parameter_list ',' T_ELLIPSIS . { ')' }\l"]; + q139 [label="139:\l parameter_list -> parameter_list ',' parameter_declaration . { ')' ',' }\l"]; + q140 [label="140:\l identifier_list -> identifier_list ',' any_id . { ')' ',' }\l"]; + q141 [label="141:\l declaration -> any_typedef decl_specifiers $$1 opt_declarator_list ';' . { ';' T_ASM T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q142 [label="142:\l declarator_list -> declarator_list ',' . declarator\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q143 [label="143:\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 . T_MATCHRBRACE\l"]; + q144 [label="144:\l direct_abs_declarator -> '(' abs_declarator ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q145 [label="145:\l direct_abs_declarator -> '(' parameter_type_list ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q146 [label="146:\l direct_abs_declarator -> direct_abs_declarator '(' ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q147 [label="147:\l direct_abs_declarator -> direct_abs_declarator '(' parameter_type_list . ')'\l"]; + q148 [label="148:\l declarator_list -> declarator_list ',' declarator . { ',' ';' }\l"]; + q149 [label="149:\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q150 [label="150:\l direct_abs_declarator -> direct_abs_declarator '(' parameter_type_list ')' . { ')' ',' T_BRACKETS '(' }\l"]; + + q0 -> q1 [label="error"]; + q0 -> q2 [label="'('"]; + q0 -> q3 [label="'*'"]; + q0 -> q4 [label="'&'"]; + q0 -> q5 [label="T_IDENTIFIER"]; + q0 -> q6 [label="T_TYPEDEF_NAME"]; + q0 -> q7 [label="T_DEFINE_NAME"]; + q0 -> q8 [label="T_AUTO"]; + q0 -> q9 [label="T_EXTERN"]; + q0 -> q10 [label="T_REGISTER"]; + q0 -> q11 [label="T_STATIC"]; + q0 -> q12 [label="T_TYPEDEF"]; + q0 -> q13 [label="T_INLINE"]; + q0 -> q14 [label="T_EXTENSION"]; + q0 -> q15 [label="T_CHAR"]; + q0 -> q16 [label="T_DOUBLE"]; + q0 -> q17 [label="T_FLOAT"]; + q0 -> q18 [label="T_INT"]; + q0 -> q19 [label="T_VOID"]; + q0 -> q20 [label="T_LONG"]; + q0 -> q21 [label="T_SHORT"]; + q0 -> q22 [label="T_SIGNED"]; + q0 -> q23 [label="T_UNSIGNED"]; + q0 -> q24 [label="T_ENUM"]; + q0 -> q25 [label="T_STRUCT"]; + q0 -> q26 [label="T_UNION"]; + q0 -> q27 [label="T_Bool"]; + q0 -> q28 [label="T_Complex"]; + q0 -> q29 [label="T_Imaginary"]; + q0 -> q30 [label="T_TYPE_QUALIFIER"]; + q0 -> q31 [label="T_ASM"]; + q0 -> q32 [label="';'"]; + q0 -> q33 [label="program"]; + q0 -> q34 [label="decl_specifiers"]; + q0 -> q35 [label="decl_specifier"]; + q0 -> q36 [label="storage_class"]; + q0 -> q37 [label="type_specifier"]; + q0 -> q38 [label="type_qualifier"]; + q0 -> q39 [label="struct_or_union_specifier"]; + q0 -> q40 [label="enum_specifier"]; + q0 -> q41 [label="declarator"]; + q0 -> q42 [label="direct_declarator"]; + q0 -> q43 [label="struct_or_union"]; + q0 -> q44 [label="pointer"]; + q0 -> q45 [label="any_id"]; + q0 -> q46 [label="identifier_or_ref"]; + q0 -> q47 [label="enumeration"]; + q0 -> q48 [label="translation_unit"]; + q0 -> q49 [label="external_declaration"]; + q0 -> q50 [label="declaration"]; + q0 -> q51 [label="function_definition"]; + q0 -> q52 [label="linkage_specification"]; + q0 -> q53 [label="any_typedef"]; + q1 -> q54 [label="T_MATCHRBRACE"]; + q1 -> q55 [label="';'"]; + q2 -> q2 [label="'('"]; + q2 -> q3 [label="'*'"]; + q2 -> q4 [label="'&'"]; + q2 -> q5 [label="T_IDENTIFIER"]; + q2 -> q56 [label="T_TYPEDEF_NAME"]; + q2 -> q57 [label="declarator"]; + q2 -> q42 [label="direct_declarator"]; + q2 -> q44 [label="pointer"]; + q2 -> q45 [label="any_id"]; + q2 -> q46 [label="identifier_or_ref"]; + q3 -> q7 [label="T_DEFINE_NAME"]; + q3 -> q30 [label="T_TYPE_QUALIFIER"]; + q3 -> q58 [label="type_qualifier"]; + q3 -> q59 [label="opt_type_qualifiers"]; + q3 -> q60 [label="type_qualifier_list"]; + q4 -> q5 [label="T_IDENTIFIER"]; + q4 -> q56 [label="T_TYPEDEF_NAME"]; + q4 -> q61 [label="any_id"]; + q9 -> q62 [label="T_STRING_LITERAL"]; + q14 -> q63 [label="T_TYPEDEF"]; + q31 -> q64 [label="T_ASMARG"]; + q34 -> q2 [label="'('"]; + q34 -> q3 [label="'*'"]; + q34 -> q4 [label="'&'"]; + q34 -> q5 [label="T_IDENTIFIER"]; + q34 -> q6 [label="T_TYPEDEF_NAME"]; + q34 -> q7 [label="T_DEFINE_NAME"]; + q34 -> q8 [label="T_AUTO"]; + q34 -> q65 [label="T_EXTERN"]; + q34 -> q10 [label="T_REGISTER"]; + q34 -> q11 [label="T_STATIC"]; + q34 -> q13 [label="T_INLINE"]; + q34 -> q66 [label="T_EXTENSION"]; + q34 -> q15 [label="T_CHAR"]; + q34 -> q16 [label="T_DOUBLE"]; + q34 -> q17 [label="T_FLOAT"]; + q34 -> q18 [label="T_INT"]; + q34 -> q19 [label="T_VOID"]; + q34 -> q20 [label="T_LONG"]; + q34 -> q21 [label="T_SHORT"]; + q34 -> q22 [label="T_SIGNED"]; + q34 -> q23 [label="T_UNSIGNED"]; + q34 -> q24 [label="T_ENUM"]; + q34 -> q25 [label="T_STRUCT"]; + q34 -> q26 [label="T_UNION"]; + q34 -> q27 [label="T_Bool"]; + q34 -> q28 [label="T_Complex"]; + q34 -> q29 [label="T_Imaginary"]; + q34 -> q30 [label="T_TYPE_QUALIFIER"]; + q34 -> q67 [label="';'"]; + q34 -> q68 [label="decl_specifier"]; + q34 -> q36 [label="storage_class"]; + q34 -> q37 [label="type_specifier"]; + q34 -> q38 [label="type_qualifier"]; + q34 -> q39 [label="struct_or_union_specifier"]; + q34 -> q40 [label="enum_specifier"]; + q34 -> q69 [label="init_declarator_list"]; + q34 -> q70 [label="init_declarator"]; + q34 -> q71 [label="declarator"]; + q34 -> q42 [label="direct_declarator"]; + q34 -> q43 [label="struct_or_union"]; + q34 -> q44 [label="pointer"]; + q34 -> q45 [label="any_id"]; + q34 -> q46 [label="identifier_or_ref"]; + q34 -> q47 [label="enumeration"]; + q41 -> q72 [label="$$4"]; + q42 -> q73 [label="'('"]; + q42 -> q74 [label="T_BRACKETS"]; + q43 -> q5 [label="T_IDENTIFIER"]; + q43 -> q56 [label="T_TYPEDEF_NAME"]; + q43 -> q75 [label="T_LBRACE"]; + q43 -> q76 [label="any_id"]; + q43 -> q77 [label="braces"]; + q44 -> q2 [label="'('"]; + q44 -> q4 [label="'&'"]; + q44 -> q5 [label="T_IDENTIFIER"]; + q44 -> q56 [label="T_TYPEDEF_NAME"]; + q44 -> q78 [label="direct_declarator"]; + q44 -> q45 [label="any_id"]; + q44 -> q46 [label="identifier_or_ref"]; + q47 -> q5 [label="T_IDENTIFIER"]; + q47 -> q56 [label="T_TYPEDEF_NAME"]; + q47 -> q75 [label="T_LBRACE"]; + q47 -> q79 [label="any_id"]; + q47 -> q80 [label="braces"]; + q48 -> q1 [label="error"]; + q48 -> q2 [label="'('"]; + q48 -> q3 [label="'*'"]; + q48 -> q4 [label="'&'"]; + q48 -> q5 [label="T_IDENTIFIER"]; + q48 -> q6 [label="T_TYPEDEF_NAME"]; + q48 -> q7 [label="T_DEFINE_NAME"]; + q48 -> q8 [label="T_AUTO"]; + q48 -> q9 [label="T_EXTERN"]; + q48 -> q10 [label="T_REGISTER"]; + q48 -> q11 [label="T_STATIC"]; + q48 -> q12 [label="T_TYPEDEF"]; + q48 -> q13 [label="T_INLINE"]; + q48 -> q14 [label="T_EXTENSION"]; + q48 -> q15 [label="T_CHAR"]; + q48 -> q16 [label="T_DOUBLE"]; + q48 -> q17 [label="T_FLOAT"]; + q48 -> q18 [label="T_INT"]; + q48 -> q19 [label="T_VOID"]; + q48 -> q20 [label="T_LONG"]; + q48 -> q21 [label="T_SHORT"]; + q48 -> q22 [label="T_SIGNED"]; + q48 -> q23 [label="T_UNSIGNED"]; + q48 -> q24 [label="T_ENUM"]; + q48 -> q25 [label="T_STRUCT"]; + q48 -> q26 [label="T_UNION"]; + q48 -> q27 [label="T_Bool"]; + q48 -> q28 [label="T_Complex"]; + q48 -> q29 [label="T_Imaginary"]; + q48 -> q30 [label="T_TYPE_QUALIFIER"]; + q48 -> q31 [label="T_ASM"]; + q48 -> q32 [label="';'"]; + q48 -> q34 [label="decl_specifiers"]; + q48 -> q35 [label="decl_specifier"]; + q48 -> q36 [label="storage_class"]; + q48 -> q37 [label="type_specifier"]; + q48 -> q38 [label="type_qualifier"]; + q48 -> q39 [label="struct_or_union_specifier"]; + q48 -> q40 [label="enum_specifier"]; + q48 -> q41 [label="declarator"]; + q48 -> q42 [label="direct_declarator"]; + q48 -> q43 [label="struct_or_union"]; + q48 -> q44 [label="pointer"]; + q48 -> q45 [label="any_id"]; + q48 -> q46 [label="identifier_or_ref"]; + q48 -> q47 [label="enumeration"]; + q48 -> q81 [label="external_declaration"]; + q48 -> q50 [label="declaration"]; + q48 -> q51 [label="function_definition"]; + q48 -> q52 [label="linkage_specification"]; + q48 -> q53 [label="any_typedef"]; + q53 -> q82 [label="T_TYPEDEF_NAME"]; + q53 -> q7 [label="T_DEFINE_NAME"]; + q53 -> q8 [label="T_AUTO"]; + q53 -> q65 [label="T_EXTERN"]; + q53 -> q10 [label="T_REGISTER"]; + q53 -> q11 [label="T_STATIC"]; + q53 -> q13 [label="T_INLINE"]; + q53 -> q66 [label="T_EXTENSION"]; + q53 -> q15 [label="T_CHAR"]; + q53 -> q16 [label="T_DOUBLE"]; + q53 -> q17 [label="T_FLOAT"]; + q53 -> q18 [label="T_INT"]; + q53 -> q19 [label="T_VOID"]; + q53 -> q20 [label="T_LONG"]; + q53 -> q21 [label="T_SHORT"]; + q53 -> q22 [label="T_SIGNED"]; + q53 -> q23 [label="T_UNSIGNED"]; + q53 -> q24 [label="T_ENUM"]; + q53 -> q25 [label="T_STRUCT"]; + q53 -> q26 [label="T_UNION"]; + q53 -> q27 [label="T_Bool"]; + q53 -> q28 [label="T_Complex"]; + q53 -> q29 [label="T_Imaginary"]; + q53 -> q30 [label="T_TYPE_QUALIFIER"]; + q53 -> q83 [label="decl_specifiers"]; + q53 -> q35 [label="decl_specifier"]; + q53 -> q36 [label="storage_class"]; + q53 -> q37 [label="type_specifier"]; + q53 -> q38 [label="type_qualifier"]; + q53 -> q39 [label="struct_or_union_specifier"]; + q53 -> q40 [label="enum_specifier"]; + q53 -> q43 [label="struct_or_union"]; + q53 -> q47 [label="enumeration"]; + q57 -> q84 [label="')'"]; + q59 -> q3 [label="'*'"]; + q59 -> q85 [label="pointer"]; + q60 -> q7 [label="T_DEFINE_NAME"]; + q60 -> q30 [label="T_TYPE_QUALIFIER"]; + q60 -> q86 [label="type_qualifier"]; + q62 -> q82 [label="T_TYPEDEF_NAME"]; + q62 -> q7 [label="T_DEFINE_NAME"]; + q62 -> q8 [label="T_AUTO"]; + q62 -> q65 [label="T_EXTERN"]; + q62 -> q10 [label="T_REGISTER"]; + q62 -> q11 [label="T_STATIC"]; + q62 -> q12 [label="T_TYPEDEF"]; + q62 -> q13 [label="T_INLINE"]; + q62 -> q14 [label="T_EXTENSION"]; + q62 -> q15 [label="T_CHAR"]; + q62 -> q16 [label="T_DOUBLE"]; + q62 -> q17 [label="T_FLOAT"]; + q62 -> q18 [label="T_INT"]; + q62 -> q19 [label="T_VOID"]; + q62 -> q20 [label="T_LONG"]; + q62 -> q21 [label="T_SHORT"]; + q62 -> q22 [label="T_SIGNED"]; + q62 -> q23 [label="T_UNSIGNED"]; + q62 -> q24 [label="T_ENUM"]; + q62 -> q25 [label="T_STRUCT"]; + q62 -> q26 [label="T_UNION"]; + q62 -> q27 [label="T_Bool"]; + q62 -> q28 [label="T_Complex"]; + q62 -> q29 [label="T_Imaginary"]; + q62 -> q30 [label="T_TYPE_QUALIFIER"]; + q62 -> q75 [label="T_LBRACE"]; + q62 -> q87 [label="decl_specifiers"]; + q62 -> q35 [label="decl_specifier"]; + q62 -> q36 [label="storage_class"]; + q62 -> q37 [label="type_specifier"]; + q62 -> q38 [label="type_qualifier"]; + q62 -> q39 [label="struct_or_union_specifier"]; + q62 -> q40 [label="enum_specifier"]; + q62 -> q43 [label="struct_or_union"]; + q62 -> q47 [label="enumeration"]; + q62 -> q88 [label="declaration"]; + q62 -> q89 [label="braces"]; + q62 -> q53 [label="any_typedef"]; + q64 -> q90 [label="';'"]; + q69 -> q91 [label="';'"]; + q69 -> q92 [label="','"]; + q71 -> q93 [label="'='"]; + q71 -> q94 [label="$$2"]; + q72 -> q82 [label="T_TYPEDEF_NAME"]; + q72 -> q7 [label="T_DEFINE_NAME"]; + q72 -> q8 [label="T_AUTO"]; + q72 -> q65 [label="T_EXTERN"]; + q72 -> q10 [label="T_REGISTER"]; + q72 -> q11 [label="T_STATIC"]; + q72 -> q12 [label="T_TYPEDEF"]; + q72 -> q13 [label="T_INLINE"]; + q72 -> q14 [label="T_EXTENSION"]; + q72 -> q15 [label="T_CHAR"]; + q72 -> q16 [label="T_DOUBLE"]; + q72 -> q17 [label="T_FLOAT"]; + q72 -> q18 [label="T_INT"]; + q72 -> q19 [label="T_VOID"]; + q72 -> q20 [label="T_LONG"]; + q72 -> q21 [label="T_SHORT"]; + q72 -> q22 [label="T_SIGNED"]; + q72 -> q23 [label="T_UNSIGNED"]; + q72 -> q24 [label="T_ENUM"]; + q72 -> q25 [label="T_STRUCT"]; + q72 -> q26 [label="T_UNION"]; + q72 -> q27 [label="T_Bool"]; + q72 -> q28 [label="T_Complex"]; + q72 -> q29 [label="T_Imaginary"]; + q72 -> q30 [label="T_TYPE_QUALIFIER"]; + q72 -> q95 [label="T_VA_DCL"]; + q72 -> q87 [label="decl_specifiers"]; + q72 -> q35 [label="decl_specifier"]; + q72 -> q36 [label="storage_class"]; + q72 -> q37 [label="type_specifier"]; + q72 -> q38 [label="type_qualifier"]; + q72 -> q39 [label="struct_or_union_specifier"]; + q72 -> q40 [label="enum_specifier"]; + q72 -> q43 [label="struct_or_union"]; + q72 -> q47 [label="enumeration"]; + q72 -> q96 [label="declaration"]; + q72 -> q53 [label="any_typedef"]; + q72 -> q97 [label="opt_declaration_list"]; + q72 -> q98 [label="declaration_list"]; + q73 -> q5 [label="T_IDENTIFIER"]; + q73 -> q6 [label="T_TYPEDEF_NAME"]; + q73 -> q7 [label="T_DEFINE_NAME"]; + q73 -> q8 [label="T_AUTO"]; + q73 -> q65 [label="T_EXTERN"]; + q73 -> q10 [label="T_REGISTER"]; + q73 -> q11 [label="T_STATIC"]; + q73 -> q13 [label="T_INLINE"]; + q73 -> q66 [label="T_EXTENSION"]; + q73 -> q15 [label="T_CHAR"]; + q73 -> q16 [label="T_DOUBLE"]; + q73 -> q17 [label="T_FLOAT"]; + q73 -> q18 [label="T_INT"]; + q73 -> q19 [label="T_VOID"]; + q73 -> q20 [label="T_LONG"]; + q73 -> q21 [label="T_SHORT"]; + q73 -> q22 [label="T_SIGNED"]; + q73 -> q23 [label="T_UNSIGNED"]; + q73 -> q24 [label="T_ENUM"]; + q73 -> q25 [label="T_STRUCT"]; + q73 -> q26 [label="T_UNION"]; + q73 -> q27 [label="T_Bool"]; + q73 -> q28 [label="T_Complex"]; + q73 -> q29 [label="T_Imaginary"]; + q73 -> q30 [label="T_TYPE_QUALIFIER"]; + q73 -> q99 [label="decl_specifiers"]; + q73 -> q35 [label="decl_specifier"]; + q73 -> q36 [label="storage_class"]; + q73 -> q37 [label="type_specifier"]; + q73 -> q38 [label="type_qualifier"]; + q73 -> q39 [label="struct_or_union_specifier"]; + q73 -> q40 [label="enum_specifier"]; + q73 -> q100 [label="parameter_type_list"]; + q73 -> q101 [label="parameter_list"]; + q73 -> q102 [label="parameter_declaration"]; + q73 -> q103 [label="opt_identifier_list"]; + q73 -> q104 [label="identifier_list"]; + q73 -> q43 [label="struct_or_union"]; + q73 -> q105 [label="any_id"]; + q73 -> q47 [label="enumeration"]; + q75 -> q106 [label="T_MATCHRBRACE"]; + q76 -> q75 [label="T_LBRACE"]; + q76 -> q107 [label="braces"]; + q78 -> q73 [label="'('"]; + q78 -> q74 [label="T_BRACKETS"]; + q79 -> q75 [label="T_LBRACE"]; + q79 -> q108 [label="braces"]; + q83 -> q82 [label="T_TYPEDEF_NAME"]; + q83 -> q7 [label="T_DEFINE_NAME"]; + q83 -> q8 [label="T_AUTO"]; + q83 -> q65 [label="T_EXTERN"]; + q83 -> q10 [label="T_REGISTER"]; + q83 -> q11 [label="T_STATIC"]; + q83 -> q13 [label="T_INLINE"]; + q83 -> q66 [label="T_EXTENSION"]; + q83 -> q15 [label="T_CHAR"]; + q83 -> q16 [label="T_DOUBLE"]; + q83 -> q17 [label="T_FLOAT"]; + q83 -> q18 [label="T_INT"]; + q83 -> q19 [label="T_VOID"]; + q83 -> q20 [label="T_LONG"]; + q83 -> q21 [label="T_SHORT"]; + q83 -> q22 [label="T_SIGNED"]; + q83 -> q23 [label="T_UNSIGNED"]; + q83 -> q24 [label="T_ENUM"]; + q83 -> q25 [label="T_STRUCT"]; + q83 -> q26 [label="T_UNION"]; + q83 -> q27 [label="T_Bool"]; + q83 -> q28 [label="T_Complex"]; + q83 -> q29 [label="T_Imaginary"]; + q83 -> q30 [label="T_TYPE_QUALIFIER"]; + q83 -> q68 [label="decl_specifier"]; + q83 -> q36 [label="storage_class"]; + q83 -> q37 [label="type_specifier"]; + q83 -> q38 [label="type_qualifier"]; + q83 -> q39 [label="struct_or_union_specifier"]; + q83 -> q40 [label="enum_specifier"]; + q83 -> q43 [label="struct_or_union"]; + q83 -> q47 [label="enumeration"]; + q83 -> q109 [label="$$1"]; + q87 -> q2 [label="'('"]; + q87 -> q3 [label="'*'"]; + q87 -> q4 [label="'&'"]; + q87 -> q5 [label="T_IDENTIFIER"]; + q87 -> q6 [label="T_TYPEDEF_NAME"]; + q87 -> q7 [label="T_DEFINE_NAME"]; + q87 -> q8 [label="T_AUTO"]; + q87 -> q65 [label="T_EXTERN"]; + q87 -> q10 [label="T_REGISTER"]; + q87 -> q11 [label="T_STATIC"]; + q87 -> q13 [label="T_INLINE"]; + q87 -> q66 [label="T_EXTENSION"]; + q87 -> q15 [label="T_CHAR"]; + q87 -> q16 [label="T_DOUBLE"]; + q87 -> q17 [label="T_FLOAT"]; + q87 -> q18 [label="T_INT"]; + q87 -> q19 [label="T_VOID"]; + q87 -> q20 [label="T_LONG"]; + q87 -> q21 [label="T_SHORT"]; + q87 -> q22 [label="T_SIGNED"]; + q87 -> q23 [label="T_UNSIGNED"]; + q87 -> q24 [label="T_ENUM"]; + q87 -> q25 [label="T_STRUCT"]; + q87 -> q26 [label="T_UNION"]; + q87 -> q27 [label="T_Bool"]; + q87 -> q28 [label="T_Complex"]; + q87 -> q29 [label="T_Imaginary"]; + q87 -> q30 [label="T_TYPE_QUALIFIER"]; + q87 -> q67 [label="';'"]; + q87 -> q68 [label="decl_specifier"]; + q87 -> q36 [label="storage_class"]; + q87 -> q37 [label="type_specifier"]; + q87 -> q38 [label="type_qualifier"]; + q87 -> q39 [label="struct_or_union_specifier"]; + q87 -> q40 [label="enum_specifier"]; + q87 -> q69 [label="init_declarator_list"]; + q87 -> q70 [label="init_declarator"]; + q87 -> q110 [label="declarator"]; + q87 -> q42 [label="direct_declarator"]; + q87 -> q43 [label="struct_or_union"]; + q87 -> q44 [label="pointer"]; + q87 -> q45 [label="any_id"]; + q87 -> q46 [label="identifier_or_ref"]; + q87 -> q47 [label="enumeration"]; + q92 -> q2 [label="'('"]; + q92 -> q3 [label="'*'"]; + q92 -> q4 [label="'&'"]; + q92 -> q5 [label="T_IDENTIFIER"]; + q92 -> q56 [label="T_TYPEDEF_NAME"]; + q92 -> q111 [label="init_declarator"]; + q92 -> q110 [label="declarator"]; + q92 -> q42 [label="direct_declarator"]; + q92 -> q44 [label="pointer"]; + q92 -> q45 [label="any_id"]; + q92 -> q46 [label="identifier_or_ref"]; + q93 -> q112 [label="$$5"]; + q94 -> q82 [label="T_TYPEDEF_NAME"]; + q94 -> q7 [label="T_DEFINE_NAME"]; + q94 -> q8 [label="T_AUTO"]; + q94 -> q65 [label="T_EXTERN"]; + q94 -> q10 [label="T_REGISTER"]; + q94 -> q11 [label="T_STATIC"]; + q94 -> q12 [label="T_TYPEDEF"]; + q94 -> q13 [label="T_INLINE"]; + q94 -> q14 [label="T_EXTENSION"]; + q94 -> q15 [label="T_CHAR"]; + q94 -> q16 [label="T_DOUBLE"]; + q94 -> q17 [label="T_FLOAT"]; + q94 -> q18 [label="T_INT"]; + q94 -> q19 [label="T_VOID"]; + q94 -> q20 [label="T_LONG"]; + q94 -> q21 [label="T_SHORT"]; + q94 -> q22 [label="T_SIGNED"]; + q94 -> q23 [label="T_UNSIGNED"]; + q94 -> q24 [label="T_ENUM"]; + q94 -> q25 [label="T_STRUCT"]; + q94 -> q26 [label="T_UNION"]; + q94 -> q27 [label="T_Bool"]; + q94 -> q28 [label="T_Complex"]; + q94 -> q29 [label="T_Imaginary"]; + q94 -> q30 [label="T_TYPE_QUALIFIER"]; + q94 -> q95 [label="T_VA_DCL"]; + q94 -> q87 [label="decl_specifiers"]; + q94 -> q35 [label="decl_specifier"]; + q94 -> q36 [label="storage_class"]; + q94 -> q37 [label="type_specifier"]; + q94 -> q38 [label="type_qualifier"]; + q94 -> q39 [label="struct_or_union_specifier"]; + q94 -> q40 [label="enum_specifier"]; + q94 -> q43 [label="struct_or_union"]; + q94 -> q47 [label="enumeration"]; + q94 -> q96 [label="declaration"]; + q94 -> q53 [label="any_typedef"]; + q94 -> q113 [label="opt_declaration_list"]; + q94 -> q98 [label="declaration_list"]; + q97 -> q114 [label="T_LBRACE"]; + q98 -> q82 [label="T_TYPEDEF_NAME"]; + q98 -> q7 [label="T_DEFINE_NAME"]; + q98 -> q8 [label="T_AUTO"]; + q98 -> q65 [label="T_EXTERN"]; + q98 -> q10 [label="T_REGISTER"]; + q98 -> q11 [label="T_STATIC"]; + q98 -> q12 [label="T_TYPEDEF"]; + q98 -> q13 [label="T_INLINE"]; + q98 -> q14 [label="T_EXTENSION"]; + q98 -> q15 [label="T_CHAR"]; + q98 -> q16 [label="T_DOUBLE"]; + q98 -> q17 [label="T_FLOAT"]; + q98 -> q18 [label="T_INT"]; + q98 -> q19 [label="T_VOID"]; + q98 -> q20 [label="T_LONG"]; + q98 -> q21 [label="T_SHORT"]; + q98 -> q22 [label="T_SIGNED"]; + q98 -> q23 [label="T_UNSIGNED"]; + q98 -> q24 [label="T_ENUM"]; + q98 -> q25 [label="T_STRUCT"]; + q98 -> q26 [label="T_UNION"]; + q98 -> q27 [label="T_Bool"]; + q98 -> q28 [label="T_Complex"]; + q98 -> q29 [label="T_Imaginary"]; + q98 -> q30 [label="T_TYPE_QUALIFIER"]; + q98 -> q87 [label="decl_specifiers"]; + q98 -> q35 [label="decl_specifier"]; + q98 -> q36 [label="storage_class"]; + q98 -> q37 [label="type_specifier"]; + q98 -> q38 [label="type_qualifier"]; + q98 -> q39 [label="struct_or_union_specifier"]; + q98 -> q40 [label="enum_specifier"]; + q98 -> q43 [label="struct_or_union"]; + q98 -> q47 [label="enumeration"]; + q98 -> q115 [label="declaration"]; + q98 -> q53 [label="any_typedef"]; + q99 -> q116 [label="'('"]; + q99 -> q3 [label="'*'"]; + q99 -> q4 [label="'&'"]; + q99 -> q5 [label="T_IDENTIFIER"]; + q99 -> q6 [label="T_TYPEDEF_NAME"]; + q99 -> q7 [label="T_DEFINE_NAME"]; + q99 -> q8 [label="T_AUTO"]; + q99 -> q65 [label="T_EXTERN"]; + q99 -> q10 [label="T_REGISTER"]; + q99 -> q11 [label="T_STATIC"]; + q99 -> q13 [label="T_INLINE"]; + q99 -> q66 [label="T_EXTENSION"]; + q99 -> q15 [label="T_CHAR"]; + q99 -> q16 [label="T_DOUBLE"]; + q99 -> q17 [label="T_FLOAT"]; + q99 -> q18 [label="T_INT"]; + q99 -> q19 [label="T_VOID"]; + q99 -> q20 [label="T_LONG"]; + q99 -> q21 [label="T_SHORT"]; + q99 -> q22 [label="T_SIGNED"]; + q99 -> q23 [label="T_UNSIGNED"]; + q99 -> q24 [label="T_ENUM"]; + q99 -> q25 [label="T_STRUCT"]; + q99 -> q26 [label="T_UNION"]; + q99 -> q27 [label="T_Bool"]; + q99 -> q28 [label="T_Complex"]; + q99 -> q29 [label="T_Imaginary"]; + q99 -> q30 [label="T_TYPE_QUALIFIER"]; + q99 -> q117 [label="T_BRACKETS"]; + q99 -> q68 [label="decl_specifier"]; + q99 -> q36 [label="storage_class"]; + q99 -> q37 [label="type_specifier"]; + q99 -> q38 [label="type_qualifier"]; + q99 -> q39 [label="struct_or_union_specifier"]; + q99 -> q40 [label="enum_specifier"]; + q99 -> q118 [label="declarator"]; + q99 -> q42 [label="direct_declarator"]; + q99 -> q119 [label="abs_declarator"]; + q99 -> q120 [label="direct_abs_declarator"]; + q99 -> q43 [label="struct_or_union"]; + q99 -> q121 [label="pointer"]; + q99 -> q45 [label="any_id"]; + q99 -> q46 [label="identifier_or_ref"]; + q99 -> q47 [label="enumeration"]; + q100 -> q122 [label="')'"]; + q101 -> q123 [label="','"]; + q103 -> q124 [label="')'"]; + q104 -> q125 [label="','"]; + q109 -> q2 [label="'('"]; + q109 -> q3 [label="'*'"]; + q109 -> q4 [label="'&'"]; + q109 -> q5 [label="T_IDENTIFIER"]; + q109 -> q56 [label="T_TYPEDEF_NAME"]; + q109 -> q126 [label="declarator"]; + q109 -> q42 [label="direct_declarator"]; + q109 -> q44 [label="pointer"]; + q109 -> q45 [label="any_id"]; + q109 -> q46 [label="identifier_or_ref"]; + q109 -> q127 [label="opt_declarator_list"]; + q109 -> q128 [label="declarator_list"]; + q110 -> q93 [label="'='"]; + q112 -> q129 [label="T_INITIALIZER"]; + q113 -> q130 [label="T_LBRACE"]; + q114 -> q131 [label="T_MATCHRBRACE"]; + q116 -> q116 [label="'('"]; + q116 -> q3 [label="'*'"]; + q116 -> q4 [label="'&'"]; + q116 -> q5 [label="T_IDENTIFIER"]; + q116 -> q6 [label="T_TYPEDEF_NAME"]; + q116 -> q7 [label="T_DEFINE_NAME"]; + q116 -> q8 [label="T_AUTO"]; + q116 -> q65 [label="T_EXTERN"]; + q116 -> q10 [label="T_REGISTER"]; + q116 -> q11 [label="T_STATIC"]; + q116 -> q13 [label="T_INLINE"]; + q116 -> q66 [label="T_EXTENSION"]; + q116 -> q15 [label="T_CHAR"]; + q116 -> q16 [label="T_DOUBLE"]; + q116 -> q17 [label="T_FLOAT"]; + q116 -> q18 [label="T_INT"]; + q116 -> q19 [label="T_VOID"]; + q116 -> q20 [label="T_LONG"]; + q116 -> q21 [label="T_SHORT"]; + q116 -> q22 [label="T_SIGNED"]; + q116 -> q23 [label="T_UNSIGNED"]; + q116 -> q24 [label="T_ENUM"]; + q116 -> q25 [label="T_STRUCT"]; + q116 -> q26 [label="T_UNION"]; + q116 -> q27 [label="T_Bool"]; + q116 -> q28 [label="T_Complex"]; + q116 -> q29 [label="T_Imaginary"]; + q116 -> q30 [label="T_TYPE_QUALIFIER"]; + q116 -> q117 [label="T_BRACKETS"]; + q116 -> q132 [label="')'"]; + q116 -> q99 [label="decl_specifiers"]; + q116 -> q35 [label="decl_specifier"]; + q116 -> q36 [label="storage_class"]; + q116 -> q37 [label="type_specifier"]; + q116 -> q38 [label="type_qualifier"]; + q116 -> q39 [label="struct_or_union_specifier"]; + q116 -> q40 [label="enum_specifier"]; + q116 -> q57 [label="declarator"]; + q116 -> q42 [label="direct_declarator"]; + q116 -> q133 [label="abs_declarator"]; + q116 -> q120 [label="direct_abs_declarator"]; + q116 -> q134 [label="parameter_type_list"]; + q116 -> q101 [label="parameter_list"]; + q116 -> q102 [label="parameter_declaration"]; + q116 -> q43 [label="struct_or_union"]; + q116 -> q121 [label="pointer"]; + q116 -> q45 [label="any_id"]; + q116 -> q46 [label="identifier_or_ref"]; + q116 -> q47 [label="enumeration"]; + q120 -> q135 [label="'('"]; + q120 -> q136 [label="T_BRACKETS"]; + q121 -> q116 [label="'('"]; + q121 -> q4 [label="'&'"]; + q121 -> q5 [label="T_IDENTIFIER"]; + q121 -> q56 [label="T_TYPEDEF_NAME"]; + q121 -> q117 [label="T_BRACKETS"]; + q121 -> q78 [label="direct_declarator"]; + q121 -> q137 [label="direct_abs_declarator"]; + q121 -> q45 [label="any_id"]; + q121 -> q46 [label="identifier_or_ref"]; + q123 -> q82 [label="T_TYPEDEF_NAME"]; + q123 -> q7 [label="T_DEFINE_NAME"]; + q123 -> q8 [label="T_AUTO"]; + q123 -> q65 [label="T_EXTERN"]; + q123 -> q10 [label="T_REGISTER"]; + q123 -> q11 [label="T_STATIC"]; + q123 -> q13 [label="T_INLINE"]; + q123 -> q66 [label="T_EXTENSION"]; + q123 -> q15 [label="T_CHAR"]; + q123 -> q16 [label="T_DOUBLE"]; + q123 -> q17 [label="T_FLOAT"]; + q123 -> q18 [label="T_INT"]; + q123 -> q19 [label="T_VOID"]; + q123 -> q20 [label="T_LONG"]; + q123 -> q21 [label="T_SHORT"]; + q123 -> q22 [label="T_SIGNED"]; + q123 -> q23 [label="T_UNSIGNED"]; + q123 -> q24 [label="T_ENUM"]; + q123 -> q25 [label="T_STRUCT"]; + q123 -> q26 [label="T_UNION"]; + q123 -> q27 [label="T_Bool"]; + q123 -> q28 [label="T_Complex"]; + q123 -> q29 [label="T_Imaginary"]; + q123 -> q30 [label="T_TYPE_QUALIFIER"]; + q123 -> q138 [label="T_ELLIPSIS"]; + q123 -> q99 [label="decl_specifiers"]; + q123 -> q35 [label="decl_specifier"]; + q123 -> q36 [label="storage_class"]; + q123 -> q37 [label="type_specifier"]; + q123 -> q38 [label="type_qualifier"]; + q123 -> q39 [label="struct_or_union_specifier"]; + q123 -> q40 [label="enum_specifier"]; + q123 -> q139 [label="parameter_declaration"]; + q123 -> q43 [label="struct_or_union"]; + q123 -> q47 [label="enumeration"]; + q125 -> q5 [label="T_IDENTIFIER"]; + q125 -> q56 [label="T_TYPEDEF_NAME"]; + q125 -> q140 [label="any_id"]; + q127 -> q141 [label="';'"]; + q128 -> q142 [label="','"]; + q130 -> q143 [label="$$3"]; + q133 -> q144 [label="')'"]; + q134 -> q145 [label="')'"]; + q135 -> q82 [label="T_TYPEDEF_NAME"]; + q135 -> q7 [label="T_DEFINE_NAME"]; + q135 -> q8 [label="T_AUTO"]; + q135 -> q65 [label="T_EXTERN"]; + q135 -> q10 [label="T_REGISTER"]; + q135 -> q11 [label="T_STATIC"]; + q135 -> q13 [label="T_INLINE"]; + q135 -> q66 [label="T_EXTENSION"]; + q135 -> q15 [label="T_CHAR"]; + q135 -> q16 [label="T_DOUBLE"]; + q135 -> q17 [label="T_FLOAT"]; + q135 -> q18 [label="T_INT"]; + q135 -> q19 [label="T_VOID"]; + q135 -> q20 [label="T_LONG"]; + q135 -> q21 [label="T_SHORT"]; + q135 -> q22 [label="T_SIGNED"]; + q135 -> q23 [label="T_UNSIGNED"]; + q135 -> q24 [label="T_ENUM"]; + q135 -> q25 [label="T_STRUCT"]; + q135 -> q26 [label="T_UNION"]; + q135 -> q27 [label="T_Bool"]; + q135 -> q28 [label="T_Complex"]; + q135 -> q29 [label="T_Imaginary"]; + q135 -> q30 [label="T_TYPE_QUALIFIER"]; + q135 -> q146 [label="')'"]; + q135 -> q99 [label="decl_specifiers"]; + q135 -> q35 [label="decl_specifier"]; + q135 -> q36 [label="storage_class"]; + q135 -> q37 [label="type_specifier"]; + q135 -> q38 [label="type_qualifier"]; + q135 -> q39 [label="struct_or_union_specifier"]; + q135 -> q40 [label="enum_specifier"]; + q135 -> q147 [label="parameter_type_list"]; + q135 -> q101 [label="parameter_list"]; + q135 -> q102 [label="parameter_declaration"]; + q135 -> q43 [label="struct_or_union"]; + q135 -> q47 [label="enumeration"]; + q137 -> q135 [label="'('"]; + q137 -> q136 [label="T_BRACKETS"]; + q142 -> q2 [label="'('"]; + q142 -> q3 [label="'*'"]; + q142 -> q4 [label="'&'"]; + q142 -> q5 [label="T_IDENTIFIER"]; + q142 -> q56 [label="T_TYPEDEF_NAME"]; + q142 -> q148 [label="declarator"]; + q142 -> q42 [label="direct_declarator"]; + q142 -> q44 [label="pointer"]; + q142 -> q45 [label="any_id"]; + q142 -> q46 [label="identifier_or_ref"]; + q143 -> q149 [label="T_MATCHRBRACE"]; + q147 -> q150 [label="')'"]; +} diff --git a/contrib/byacc/test/btyacc/grammar.error b/contrib/byacc/test/btyacc/grammar.error new file mode 100644 index 000000000..d442f8aba --- /dev/null +++ b/contrib/byacc/test/btyacc/grammar.error @@ -0,0 +1 @@ +YACC: 1 shift/reduce conflict, 29 reduce/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/grammar.output b/contrib/byacc/test/btyacc/grammar.output new file mode 100644 index 000000000..8000cca1a --- /dev/null +++ b/contrib/byacc/test/btyacc/grammar.output @@ -0,0 +1,2304 @@ + 0 $accept : program $end + + 1 program : + 2 | translation_unit + + 3 translation_unit : external_declaration + 4 | translation_unit external_declaration + + 5 external_declaration : declaration + 6 | function_definition + 7 | ';' + 8 | linkage_specification + 9 | T_ASM T_ASMARG ';' + 10 | error T_MATCHRBRACE + 11 | error ';' + + 12 braces : T_LBRACE T_MATCHRBRACE + + 13 linkage_specification : T_EXTERN T_STRING_LITERAL braces + 14 | T_EXTERN T_STRING_LITERAL declaration + + 15 declaration : decl_specifiers ';' + 16 | decl_specifiers init_declarator_list ';' + + 17 $$1 : + + 18 declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';' + + 19 any_typedef : T_EXTENSION T_TYPEDEF + 20 | T_TYPEDEF + + 21 opt_declarator_list : + 22 | declarator_list + + 23 declarator_list : declarator + 24 | declarator_list ',' declarator + + 25 $$2 : + + 26 $$3 : + + 27 function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE + + 28 $$4 : + + 29 function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE + + 30 opt_declaration_list : + 31 | T_VA_DCL + 32 | declaration_list + + 33 declaration_list : declaration + 34 | declaration_list declaration + + 35 decl_specifiers : decl_specifier + 36 | decl_specifiers decl_specifier + + 37 decl_specifier : storage_class + 38 | type_specifier + 39 | type_qualifier + + 40 storage_class : T_AUTO + 41 | T_EXTERN + 42 | T_REGISTER + 43 | T_STATIC + 44 | T_INLINE + 45 | T_EXTENSION + + 46 type_specifier : T_CHAR + 47 | T_DOUBLE + 48 | T_FLOAT + 49 | T_INT + 50 | T_LONG + 51 | T_SHORT + 52 | T_SIGNED + 53 | T_UNSIGNED + 54 | T_VOID + 55 | T_Bool + 56 | T_Complex + 57 | T_Imaginary + 58 | T_TYPEDEF_NAME + 59 | struct_or_union_specifier + 60 | enum_specifier + + 61 type_qualifier : T_TYPE_QUALIFIER + 62 | T_DEFINE_NAME + + 63 struct_or_union_specifier : struct_or_union any_id braces + 64 | struct_or_union braces + 65 | struct_or_union any_id + + 66 struct_or_union : T_STRUCT + 67 | T_UNION + + 68 init_declarator_list : init_declarator + 69 | init_declarator_list ',' init_declarator + + 70 init_declarator : declarator + + 71 $$5 : + + 72 init_declarator : declarator '=' $$5 T_INITIALIZER + + 73 enum_specifier : enumeration any_id braces + 74 | enumeration braces + 75 | enumeration any_id + + 76 enumeration : T_ENUM + + 77 any_id : T_IDENTIFIER + 78 | T_TYPEDEF_NAME + + 79 declarator : pointer direct_declarator + 80 | direct_declarator + + 81 direct_declarator : identifier_or_ref + 82 | '(' declarator ')' + 83 | direct_declarator T_BRACKETS + 84 | direct_declarator '(' parameter_type_list ')' + 85 | direct_declarator '(' opt_identifier_list ')' + + 86 pointer : '*' opt_type_qualifiers + 87 | '*' opt_type_qualifiers pointer + + 88 opt_type_qualifiers : + 89 | type_qualifier_list + + 90 type_qualifier_list : type_qualifier + 91 | type_qualifier_list type_qualifier + + 92 parameter_type_list : parameter_list + 93 | parameter_list ',' T_ELLIPSIS + + 94 parameter_list : parameter_declaration + 95 | parameter_list ',' parameter_declaration + + 96 parameter_declaration : decl_specifiers declarator + 97 | decl_specifiers abs_declarator + 98 | decl_specifiers + + 99 opt_identifier_list : + 100 | identifier_list + + 101 identifier_list : any_id + 102 | identifier_list ',' any_id + + 103 identifier_or_ref : any_id + 104 | '&' any_id + + 105 abs_declarator : pointer + 106 | pointer direct_abs_declarator + 107 | direct_abs_declarator + + 108 direct_abs_declarator : '(' abs_declarator ')' + 109 | direct_abs_declarator T_BRACKETS + 110 | T_BRACKETS + 111 | direct_abs_declarator '(' parameter_type_list ')' + 112 | direct_abs_declarator '(' ')' + 113 | '(' parameter_type_list ')' + 114 | '(' ')' + +state 0 + $accept : . program $end (0) + program : . (1) + + error shift 1 + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 6 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 9 + T_REGISTER shift 10 + T_STATIC shift 11 + T_TYPEDEF shift 12 + T_INLINE shift 13 + T_EXTENSION shift 14 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_ASM shift 31 + ';' shift 32 + $end reduce 1 + + program goto 33 + decl_specifiers goto 34 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + declarator goto 41 + direct_declarator goto 42 + struct_or_union goto 43 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + enumeration goto 47 + translation_unit goto 48 + external_declaration goto 49 + declaration goto 50 + function_definition goto 51 + linkage_specification goto 52 + any_typedef goto 53 + + +state 1 + external_declaration : error . T_MATCHRBRACE (10) + external_declaration : error . ';' (11) + + T_MATCHRBRACE shift 54 + ';' shift 55 + . error + + +state 2 + direct_declarator : '(' . declarator ')' (82) + + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + . error + + declarator goto 57 + direct_declarator goto 42 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + + +state 3 + pointer : '*' . opt_type_qualifiers (86) + pointer : '*' . opt_type_qualifiers pointer (87) + opt_type_qualifiers : . (88) + + T_DEFINE_NAME shift 7 + T_TYPE_QUALIFIER shift 30 + '(' reduce 88 + '*' reduce 88 + '&' reduce 88 + T_IDENTIFIER reduce 88 + T_TYPEDEF_NAME reduce 88 + T_BRACKETS reduce 88 + ',' reduce 88 + ')' reduce 88 + + type_qualifier goto 58 + opt_type_qualifiers goto 59 + type_qualifier_list goto 60 + + +state 4 + identifier_or_ref : '&' . any_id (104) + + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + . error + + any_id goto 61 + + +state 5 + any_id : T_IDENTIFIER . (77) + + . reduce 77 + + +6: reduce/reduce conflict (reduce 58, reduce 78) on '(' +6: reduce/reduce conflict (reduce 58, reduce 78) on T_TYPEDEF_NAME +6: reduce/reduce conflict (reduce 58, reduce 78) on T_DEFINE_NAME +6: reduce/reduce conflict (reduce 58, reduce 78) on T_AUTO +6: reduce/reduce conflict (reduce 58, reduce 78) on T_EXTERN +6: reduce/reduce conflict (reduce 58, reduce 78) on T_REGISTER +6: reduce/reduce conflict (reduce 58, reduce 78) on T_STATIC +6: reduce/reduce conflict (reduce 58, reduce 78) on T_INLINE +6: reduce/reduce conflict (reduce 58, reduce 78) on T_EXTENSION +6: reduce/reduce conflict (reduce 58, reduce 78) on T_CHAR +6: reduce/reduce conflict (reduce 58, reduce 78) on T_DOUBLE +6: reduce/reduce conflict (reduce 58, reduce 78) on T_FLOAT +6: reduce/reduce conflict (reduce 58, reduce 78) on T_INT +6: reduce/reduce conflict (reduce 58, reduce 78) on T_VOID +6: reduce/reduce conflict (reduce 58, reduce 78) on T_LONG +6: reduce/reduce conflict (reduce 58, reduce 78) on T_SHORT +6: reduce/reduce conflict (reduce 58, reduce 78) on T_SIGNED +6: reduce/reduce conflict (reduce 58, reduce 78) on T_UNSIGNED +6: reduce/reduce conflict (reduce 58, reduce 78) on T_ENUM +6: reduce/reduce conflict (reduce 58, reduce 78) on T_STRUCT +6: reduce/reduce conflict (reduce 58, reduce 78) on T_UNION +6: reduce/reduce conflict (reduce 58, reduce 78) on T_Bool +6: reduce/reduce conflict (reduce 58, reduce 78) on T_Complex +6: reduce/reduce conflict (reduce 58, reduce 78) on T_Imaginary +6: reduce/reduce conflict (reduce 58, reduce 78) on T_TYPE_QUALIFIER +6: reduce/reduce conflict (reduce 58, reduce 78) on T_BRACKETS +6: reduce/reduce conflict (reduce 58, reduce 78) on ';' +6: reduce/reduce conflict (reduce 58, reduce 78) on ',' +6: reduce/reduce conflict (reduce 58, reduce 78) on ')' +state 6 + type_specifier : T_TYPEDEF_NAME . (58) + any_id : T_TYPEDEF_NAME . (78) + + '(' reduce 58 + '*' reduce 58 + '&' reduce 58 + T_IDENTIFIER reduce 58 + T_TYPEDEF_NAME reduce 58 + T_DEFINE_NAME reduce 58 + T_AUTO reduce 58 + T_EXTERN reduce 58 + T_REGISTER reduce 58 + T_STATIC reduce 58 + T_TYPEDEF reduce 78 + T_INLINE reduce 58 + T_EXTENSION reduce 58 + T_CHAR reduce 58 + T_DOUBLE reduce 58 + T_FLOAT reduce 58 + T_INT reduce 58 + T_VOID reduce 58 + T_LONG reduce 58 + T_SHORT reduce 58 + T_SIGNED reduce 58 + T_UNSIGNED reduce 58 + T_ENUM reduce 58 + T_STRUCT reduce 58 + T_UNION reduce 58 + T_Bool reduce 58 + T_Complex reduce 58 + T_Imaginary reduce 58 + T_TYPE_QUALIFIER reduce 58 + T_BRACKETS reduce 58 + T_LBRACE reduce 78 + T_VA_DCL reduce 78 + ';' reduce 58 + ',' reduce 58 + '=' reduce 78 + ')' reduce 58 + + +state 7 + type_qualifier : T_DEFINE_NAME . (62) + + . reduce 62 + + +state 8 + storage_class : T_AUTO . (40) + + . reduce 40 + + +state 9 + linkage_specification : T_EXTERN . T_STRING_LITERAL braces (13) + linkage_specification : T_EXTERN . T_STRING_LITERAL declaration (14) + storage_class : T_EXTERN . (41) + + T_STRING_LITERAL shift 62 + '(' reduce 41 + '*' reduce 41 + '&' reduce 41 + T_IDENTIFIER reduce 41 + T_TYPEDEF_NAME reduce 41 + T_DEFINE_NAME reduce 41 + T_AUTO reduce 41 + T_EXTERN reduce 41 + T_REGISTER reduce 41 + T_STATIC reduce 41 + T_INLINE reduce 41 + T_EXTENSION reduce 41 + T_CHAR reduce 41 + T_DOUBLE reduce 41 + T_FLOAT reduce 41 + T_INT reduce 41 + T_VOID reduce 41 + T_LONG reduce 41 + T_SHORT reduce 41 + T_SIGNED reduce 41 + T_UNSIGNED reduce 41 + T_ENUM reduce 41 + T_STRUCT reduce 41 + T_UNION reduce 41 + T_Bool reduce 41 + T_Complex reduce 41 + T_Imaginary reduce 41 + T_TYPE_QUALIFIER reduce 41 + ';' reduce 41 + + +state 10 + storage_class : T_REGISTER . (42) + + . reduce 42 + + +state 11 + storage_class : T_STATIC . (43) + + . reduce 43 + + +state 12 + any_typedef : T_TYPEDEF . (20) + + . reduce 20 + + +state 13 + storage_class : T_INLINE . (44) + + . reduce 44 + + +state 14 + any_typedef : T_EXTENSION . T_TYPEDEF (19) + storage_class : T_EXTENSION . (45) + + T_TYPEDEF shift 63 + '(' reduce 45 + '*' reduce 45 + '&' reduce 45 + T_IDENTIFIER reduce 45 + T_TYPEDEF_NAME reduce 45 + T_DEFINE_NAME reduce 45 + T_AUTO reduce 45 + T_EXTERN reduce 45 + T_REGISTER reduce 45 + T_STATIC reduce 45 + T_INLINE reduce 45 + T_EXTENSION reduce 45 + T_CHAR reduce 45 + T_DOUBLE reduce 45 + T_FLOAT reduce 45 + T_INT reduce 45 + T_VOID reduce 45 + T_LONG reduce 45 + T_SHORT reduce 45 + T_SIGNED reduce 45 + T_UNSIGNED reduce 45 + T_ENUM reduce 45 + T_STRUCT reduce 45 + T_UNION reduce 45 + T_Bool reduce 45 + T_Complex reduce 45 + T_Imaginary reduce 45 + T_TYPE_QUALIFIER reduce 45 + ';' reduce 45 + + +state 15 + type_specifier : T_CHAR . (46) + + . reduce 46 + + +state 16 + type_specifier : T_DOUBLE . (47) + + . reduce 47 + + +state 17 + type_specifier : T_FLOAT . (48) + + . reduce 48 + + +state 18 + type_specifier : T_INT . (49) + + . reduce 49 + + +state 19 + type_specifier : T_VOID . (54) + + . reduce 54 + + +state 20 + type_specifier : T_LONG . (50) + + . reduce 50 + + +state 21 + type_specifier : T_SHORT . (51) + + . reduce 51 + + +state 22 + type_specifier : T_SIGNED . (52) + + . reduce 52 + + +state 23 + type_specifier : T_UNSIGNED . (53) + + . reduce 53 + + +state 24 + enumeration : T_ENUM . (76) + + . reduce 76 + + +state 25 + struct_or_union : T_STRUCT . (66) + + . reduce 66 + + +state 26 + struct_or_union : T_UNION . (67) + + . reduce 67 + + +state 27 + type_specifier : T_Bool . (55) + + . reduce 55 + + +state 28 + type_specifier : T_Complex . (56) + + . reduce 56 + + +state 29 + type_specifier : T_Imaginary . (57) + + . reduce 57 + + +state 30 + type_qualifier : T_TYPE_QUALIFIER . (61) + + . reduce 61 + + +state 31 + external_declaration : T_ASM . T_ASMARG ';' (9) + + T_ASMARG shift 64 + . error + + +state 32 + external_declaration : ';' . (7) + + . reduce 7 + + +state 33 + $accept : program . $end (0) + + $end accept + + +state 34 + declaration : decl_specifiers . ';' (15) + declaration : decl_specifiers . init_declarator_list ';' (16) + function_definition : decl_specifiers . declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE (27) + decl_specifiers : decl_specifiers . decl_specifier (36) + + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 6 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + ';' shift 67 + . error + + decl_specifier goto 68 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + init_declarator_list goto 69 + init_declarator goto 70 + declarator goto 71 + direct_declarator goto 42 + struct_or_union goto 43 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + enumeration goto 47 + + +state 35 + decl_specifiers : decl_specifier . (35) + + . reduce 35 + + +state 36 + decl_specifier : storage_class . (37) + + . reduce 37 + + +state 37 + decl_specifier : type_specifier . (38) + + . reduce 38 + + +state 38 + decl_specifier : type_qualifier . (39) + + . reduce 39 + + +state 39 + type_specifier : struct_or_union_specifier . (59) + + . reduce 59 + + +state 40 + type_specifier : enum_specifier . (60) + + . reduce 60 + + +state 41 + function_definition : declarator . $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE (29) + $$4 : . (28) + + . reduce 28 + + $$4 goto 72 + + +state 42 + declarator : direct_declarator . (80) + direct_declarator : direct_declarator . T_BRACKETS (83) + direct_declarator : direct_declarator . '(' parameter_type_list ')' (84) + direct_declarator : direct_declarator . '(' opt_identifier_list ')' (85) + + '(' shift 73 + T_BRACKETS shift 74 + T_TYPEDEF_NAME reduce 80 + T_DEFINE_NAME reduce 80 + T_AUTO reduce 80 + T_EXTERN reduce 80 + T_REGISTER reduce 80 + T_STATIC reduce 80 + T_TYPEDEF reduce 80 + T_INLINE reduce 80 + T_EXTENSION reduce 80 + T_CHAR reduce 80 + T_DOUBLE reduce 80 + T_FLOAT reduce 80 + T_INT reduce 80 + T_VOID reduce 80 + T_LONG reduce 80 + T_SHORT reduce 80 + T_SIGNED reduce 80 + T_UNSIGNED reduce 80 + T_ENUM reduce 80 + T_STRUCT reduce 80 + T_UNION reduce 80 + T_Bool reduce 80 + T_Complex reduce 80 + T_Imaginary reduce 80 + T_TYPE_QUALIFIER reduce 80 + T_LBRACE reduce 80 + T_VA_DCL reduce 80 + ';' reduce 80 + ',' reduce 80 + '=' reduce 80 + ')' reduce 80 + + +state 43 + struct_or_union_specifier : struct_or_union . any_id braces (63) + struct_or_union_specifier : struct_or_union . braces (64) + struct_or_union_specifier : struct_or_union . any_id (65) + + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + T_LBRACE shift 75 + . error + + any_id goto 76 + braces goto 77 + + +state 44 + declarator : pointer . direct_declarator (79) + + '(' shift 2 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + . error + + direct_declarator goto 78 + any_id goto 45 + identifier_or_ref goto 46 + + +state 45 + identifier_or_ref : any_id . (103) + + . reduce 103 + + +state 46 + direct_declarator : identifier_or_ref . (81) + + . reduce 81 + + +state 47 + enum_specifier : enumeration . any_id braces (73) + enum_specifier : enumeration . braces (74) + enum_specifier : enumeration . any_id (75) + + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + T_LBRACE shift 75 + . error + + any_id goto 79 + braces goto 80 + + +state 48 + program : translation_unit . (2) + translation_unit : translation_unit . external_declaration (4) + + error shift 1 + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 6 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 9 + T_REGISTER shift 10 + T_STATIC shift 11 + T_TYPEDEF shift 12 + T_INLINE shift 13 + T_EXTENSION shift 14 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_ASM shift 31 + ';' shift 32 + $end reduce 2 + + decl_specifiers goto 34 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + declarator goto 41 + direct_declarator goto 42 + struct_or_union goto 43 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + enumeration goto 47 + external_declaration goto 81 + declaration goto 50 + function_definition goto 51 + linkage_specification goto 52 + any_typedef goto 53 + + +state 49 + translation_unit : external_declaration . (3) + + . reduce 3 + + +state 50 + external_declaration : declaration . (5) + + . reduce 5 + + +state 51 + external_declaration : function_definition . (6) + + . reduce 6 + + +state 52 + external_declaration : linkage_specification . (8) + + . reduce 8 + + +state 53 + declaration : any_typedef . decl_specifiers $$1 opt_declarator_list ';' (18) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + . error + + decl_specifiers goto 83 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + struct_or_union goto 43 + enumeration goto 47 + + +state 54 + external_declaration : error T_MATCHRBRACE . (10) + + . reduce 10 + + +state 55 + external_declaration : error ';' . (11) + + . reduce 11 + + +state 56 + any_id : T_TYPEDEF_NAME . (78) + + . reduce 78 + + +state 57 + direct_declarator : '(' declarator . ')' (82) + + ')' shift 84 + . error + + +state 58 + type_qualifier_list : type_qualifier . (90) + + . reduce 90 + + +state 59 + pointer : '*' opt_type_qualifiers . (86) + pointer : '*' opt_type_qualifiers . pointer (87) + + '*' shift 3 + '(' reduce 86 + '&' reduce 86 + T_IDENTIFIER reduce 86 + T_TYPEDEF_NAME reduce 86 + T_BRACKETS reduce 86 + ',' reduce 86 + ')' reduce 86 + + pointer goto 85 + + +state 60 + opt_type_qualifiers : type_qualifier_list . (89) + type_qualifier_list : type_qualifier_list . type_qualifier (91) + + T_DEFINE_NAME shift 7 + T_TYPE_QUALIFIER shift 30 + '(' reduce 89 + '*' reduce 89 + '&' reduce 89 + T_IDENTIFIER reduce 89 + T_TYPEDEF_NAME reduce 89 + T_BRACKETS reduce 89 + ',' reduce 89 + ')' reduce 89 + + type_qualifier goto 86 + + +state 61 + identifier_or_ref : '&' any_id . (104) + + . reduce 104 + + +state 62 + linkage_specification : T_EXTERN T_STRING_LITERAL . braces (13) + linkage_specification : T_EXTERN T_STRING_LITERAL . declaration (14) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_TYPEDEF shift 12 + T_INLINE shift 13 + T_EXTENSION shift 14 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_LBRACE shift 75 + . error + + decl_specifiers goto 87 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + struct_or_union goto 43 + enumeration goto 47 + declaration goto 88 + braces goto 89 + any_typedef goto 53 + + +state 63 + any_typedef : T_EXTENSION T_TYPEDEF . (19) + + . reduce 19 + + +state 64 + external_declaration : T_ASM T_ASMARG . ';' (9) + + ';' shift 90 + . error + + +state 65 + storage_class : T_EXTERN . (41) + + . reduce 41 + + +state 66 + storage_class : T_EXTENSION . (45) + + . reduce 45 + + +state 67 + declaration : decl_specifiers ';' . (15) + + . reduce 15 + + +state 68 + decl_specifiers : decl_specifiers decl_specifier . (36) + + . reduce 36 + + +state 69 + declaration : decl_specifiers init_declarator_list . ';' (16) + init_declarator_list : init_declarator_list . ',' init_declarator (69) + + ';' shift 91 + ',' shift 92 + . error + + +state 70 + init_declarator_list : init_declarator . (68) + + . reduce 68 + + +state 71 + function_definition : decl_specifiers declarator . $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE (27) + init_declarator : declarator . (70) + init_declarator : declarator . '=' $$5 T_INITIALIZER (72) + $$2 : . (25) + + '=' shift 93 + T_TYPEDEF_NAME reduce 25 + T_DEFINE_NAME reduce 25 + T_AUTO reduce 25 + T_EXTERN reduce 25 + T_REGISTER reduce 25 + T_STATIC reduce 25 + T_TYPEDEF reduce 25 + T_INLINE reduce 25 + T_EXTENSION reduce 25 + T_CHAR reduce 25 + T_DOUBLE reduce 25 + T_FLOAT reduce 25 + T_INT reduce 25 + T_VOID reduce 25 + T_LONG reduce 25 + T_SHORT reduce 25 + T_SIGNED reduce 25 + T_UNSIGNED reduce 25 + T_ENUM reduce 25 + T_STRUCT reduce 25 + T_UNION reduce 25 + T_Bool reduce 25 + T_Complex reduce 25 + T_Imaginary reduce 25 + T_TYPE_QUALIFIER reduce 25 + T_LBRACE reduce 25 + T_VA_DCL reduce 25 + ';' reduce 70 + ',' reduce 70 + + $$2 goto 94 + + +state 72 + function_definition : declarator $$4 . opt_declaration_list T_LBRACE T_MATCHRBRACE (29) + opt_declaration_list : . (30) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_TYPEDEF shift 12 + T_INLINE shift 13 + T_EXTENSION shift 14 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_VA_DCL shift 95 + T_LBRACE reduce 30 + + decl_specifiers goto 87 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + struct_or_union goto 43 + enumeration goto 47 + declaration goto 96 + any_typedef goto 53 + opt_declaration_list goto 97 + declaration_list goto 98 + + +state 73 + direct_declarator : direct_declarator '(' . parameter_type_list ')' (84) + direct_declarator : direct_declarator '(' . opt_identifier_list ')' (85) + opt_identifier_list : . (99) + + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 6 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + ')' reduce 99 + + decl_specifiers goto 99 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + parameter_type_list goto 100 + parameter_list goto 101 + parameter_declaration goto 102 + opt_identifier_list goto 103 + identifier_list goto 104 + struct_or_union goto 43 + any_id goto 105 + enumeration goto 47 + + +state 74 + direct_declarator : direct_declarator T_BRACKETS . (83) + + . reduce 83 + + +state 75 + braces : T_LBRACE . T_MATCHRBRACE (12) + + T_MATCHRBRACE shift 106 + . error + + +state 76 + struct_or_union_specifier : struct_or_union any_id . braces (63) + struct_or_union_specifier : struct_or_union any_id . (65) + + T_LBRACE shift 75 + '(' reduce 65 + '*' reduce 65 + '&' reduce 65 + T_IDENTIFIER reduce 65 + T_TYPEDEF_NAME reduce 65 + T_DEFINE_NAME reduce 65 + T_AUTO reduce 65 + T_EXTERN reduce 65 + T_REGISTER reduce 65 + T_STATIC reduce 65 + T_INLINE reduce 65 + T_EXTENSION reduce 65 + T_CHAR reduce 65 + T_DOUBLE reduce 65 + T_FLOAT reduce 65 + T_INT reduce 65 + T_VOID reduce 65 + T_LONG reduce 65 + T_SHORT reduce 65 + T_SIGNED reduce 65 + T_UNSIGNED reduce 65 + T_ENUM reduce 65 + T_STRUCT reduce 65 + T_UNION reduce 65 + T_Bool reduce 65 + T_Complex reduce 65 + T_Imaginary reduce 65 + T_TYPE_QUALIFIER reduce 65 + T_BRACKETS reduce 65 + ';' reduce 65 + ',' reduce 65 + ')' reduce 65 + + braces goto 107 + + +state 77 + struct_or_union_specifier : struct_or_union braces . (64) + + . reduce 64 + + +state 78 + declarator : pointer direct_declarator . (79) + direct_declarator : direct_declarator . T_BRACKETS (83) + direct_declarator : direct_declarator . '(' parameter_type_list ')' (84) + direct_declarator : direct_declarator . '(' opt_identifier_list ')' (85) + + '(' shift 73 + T_BRACKETS shift 74 + T_TYPEDEF_NAME reduce 79 + T_DEFINE_NAME reduce 79 + T_AUTO reduce 79 + T_EXTERN reduce 79 + T_REGISTER reduce 79 + T_STATIC reduce 79 + T_TYPEDEF reduce 79 + T_INLINE reduce 79 + T_EXTENSION reduce 79 + T_CHAR reduce 79 + T_DOUBLE reduce 79 + T_FLOAT reduce 79 + T_INT reduce 79 + T_VOID reduce 79 + T_LONG reduce 79 + T_SHORT reduce 79 + T_SIGNED reduce 79 + T_UNSIGNED reduce 79 + T_ENUM reduce 79 + T_STRUCT reduce 79 + T_UNION reduce 79 + T_Bool reduce 79 + T_Complex reduce 79 + T_Imaginary reduce 79 + T_TYPE_QUALIFIER reduce 79 + T_LBRACE reduce 79 + T_VA_DCL reduce 79 + ';' reduce 79 + ',' reduce 79 + '=' reduce 79 + ')' reduce 79 + + +state 79 + enum_specifier : enumeration any_id . braces (73) + enum_specifier : enumeration any_id . (75) + + T_LBRACE shift 75 + '(' reduce 75 + '*' reduce 75 + '&' reduce 75 + T_IDENTIFIER reduce 75 + T_TYPEDEF_NAME reduce 75 + T_DEFINE_NAME reduce 75 + T_AUTO reduce 75 + T_EXTERN reduce 75 + T_REGISTER reduce 75 + T_STATIC reduce 75 + T_INLINE reduce 75 + T_EXTENSION reduce 75 + T_CHAR reduce 75 + T_DOUBLE reduce 75 + T_FLOAT reduce 75 + T_INT reduce 75 + T_VOID reduce 75 + T_LONG reduce 75 + T_SHORT reduce 75 + T_SIGNED reduce 75 + T_UNSIGNED reduce 75 + T_ENUM reduce 75 + T_STRUCT reduce 75 + T_UNION reduce 75 + T_Bool reduce 75 + T_Complex reduce 75 + T_Imaginary reduce 75 + T_TYPE_QUALIFIER reduce 75 + T_BRACKETS reduce 75 + ';' reduce 75 + ',' reduce 75 + ')' reduce 75 + + braces goto 108 + + +state 80 + enum_specifier : enumeration braces . (74) + + . reduce 74 + + +state 81 + translation_unit : translation_unit external_declaration . (4) + + . reduce 4 + + +state 82 + type_specifier : T_TYPEDEF_NAME . (58) + + . reduce 58 + + +83: shift/reduce conflict (shift 82, reduce 17) on T_TYPEDEF_NAME +state 83 + declaration : any_typedef decl_specifiers . $$1 opt_declarator_list ';' (18) + decl_specifiers : decl_specifiers . decl_specifier (36) + $$1 : . (17) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + '(' reduce 17 + '*' reduce 17 + '&' reduce 17 + T_IDENTIFIER reduce 17 + ';' reduce 17 + + decl_specifier goto 68 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + struct_or_union goto 43 + enumeration goto 47 + $$1 goto 109 + + +state 84 + direct_declarator : '(' declarator ')' . (82) + + . reduce 82 + + +state 85 + pointer : '*' opt_type_qualifiers pointer . (87) + + . reduce 87 + + +state 86 + type_qualifier_list : type_qualifier_list type_qualifier . (91) + + . reduce 91 + + +state 87 + declaration : decl_specifiers . ';' (15) + declaration : decl_specifiers . init_declarator_list ';' (16) + decl_specifiers : decl_specifiers . decl_specifier (36) + + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 6 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + ';' shift 67 + . error + + decl_specifier goto 68 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + init_declarator_list goto 69 + init_declarator goto 70 + declarator goto 110 + direct_declarator goto 42 + struct_or_union goto 43 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + enumeration goto 47 + + +state 88 + linkage_specification : T_EXTERN T_STRING_LITERAL declaration . (14) + + . reduce 14 + + +state 89 + linkage_specification : T_EXTERN T_STRING_LITERAL braces . (13) + + . reduce 13 + + +state 90 + external_declaration : T_ASM T_ASMARG ';' . (9) + + . reduce 9 + + +state 91 + declaration : decl_specifiers init_declarator_list ';' . (16) + + . reduce 16 + + +state 92 + init_declarator_list : init_declarator_list ',' . init_declarator (69) + + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + . error + + init_declarator goto 111 + declarator goto 110 + direct_declarator goto 42 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + + +state 93 + init_declarator : declarator '=' . $$5 T_INITIALIZER (72) + $$5 : . (71) + + . reduce 71 + + $$5 goto 112 + + +state 94 + function_definition : decl_specifiers declarator $$2 . opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE (27) + opt_declaration_list : . (30) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_TYPEDEF shift 12 + T_INLINE shift 13 + T_EXTENSION shift 14 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_VA_DCL shift 95 + T_LBRACE reduce 30 + + decl_specifiers goto 87 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + struct_or_union goto 43 + enumeration goto 47 + declaration goto 96 + any_typedef goto 53 + opt_declaration_list goto 113 + declaration_list goto 98 + + +state 95 + opt_declaration_list : T_VA_DCL . (31) + + . reduce 31 + + +state 96 + declaration_list : declaration . (33) + + . reduce 33 + + +state 97 + function_definition : declarator $$4 opt_declaration_list . T_LBRACE T_MATCHRBRACE (29) + + T_LBRACE shift 114 + . error + + +state 98 + opt_declaration_list : declaration_list . (32) + declaration_list : declaration_list . declaration (34) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_TYPEDEF shift 12 + T_INLINE shift 13 + T_EXTENSION shift 14 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_LBRACE reduce 32 + + decl_specifiers goto 87 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + struct_or_union goto 43 + enumeration goto 47 + declaration goto 115 + any_typedef goto 53 + + +state 99 + decl_specifiers : decl_specifiers . decl_specifier (36) + parameter_declaration : decl_specifiers . declarator (96) + parameter_declaration : decl_specifiers . abs_declarator (97) + parameter_declaration : decl_specifiers . (98) + + '(' shift 116 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 6 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_BRACKETS shift 117 + ',' reduce 98 + ')' reduce 98 + + decl_specifier goto 68 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + declarator goto 118 + direct_declarator goto 42 + abs_declarator goto 119 + direct_abs_declarator goto 120 + struct_or_union goto 43 + pointer goto 121 + any_id goto 45 + identifier_or_ref goto 46 + enumeration goto 47 + + +state 100 + direct_declarator : direct_declarator '(' parameter_type_list . ')' (84) + + ')' shift 122 + . error + + +state 101 + parameter_type_list : parameter_list . (92) + parameter_type_list : parameter_list . ',' T_ELLIPSIS (93) + parameter_list : parameter_list . ',' parameter_declaration (95) + + ',' shift 123 + ')' reduce 92 + + +state 102 + parameter_list : parameter_declaration . (94) + + . reduce 94 + + +state 103 + direct_declarator : direct_declarator '(' opt_identifier_list . ')' (85) + + ')' shift 124 + . error + + +state 104 + opt_identifier_list : identifier_list . (100) + identifier_list : identifier_list . ',' any_id (102) + + ',' shift 125 + ')' reduce 100 + + +state 105 + identifier_list : any_id . (101) + + . reduce 101 + + +state 106 + braces : T_LBRACE T_MATCHRBRACE . (12) + + . reduce 12 + + +state 107 + struct_or_union_specifier : struct_or_union any_id braces . (63) + + . reduce 63 + + +state 108 + enum_specifier : enumeration any_id braces . (73) + + . reduce 73 + + +state 109 + declaration : any_typedef decl_specifiers $$1 . opt_declarator_list ';' (18) + opt_declarator_list : . (21) + + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + ';' reduce 21 + + declarator goto 126 + direct_declarator goto 42 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + opt_declarator_list goto 127 + declarator_list goto 128 + + +state 110 + init_declarator : declarator . (70) + init_declarator : declarator . '=' $$5 T_INITIALIZER (72) + + '=' shift 93 + ';' reduce 70 + ',' reduce 70 + + +state 111 + init_declarator_list : init_declarator_list ',' init_declarator . (69) + + . reduce 69 + + +state 112 + init_declarator : declarator '=' $$5 . T_INITIALIZER (72) + + T_INITIALIZER shift 129 + . error + + +state 113 + function_definition : decl_specifiers declarator $$2 opt_declaration_list . T_LBRACE $$3 T_MATCHRBRACE (27) + + T_LBRACE shift 130 + . error + + +state 114 + function_definition : declarator $$4 opt_declaration_list T_LBRACE . T_MATCHRBRACE (29) + + T_MATCHRBRACE shift 131 + . error + + +state 115 + declaration_list : declaration_list declaration . (34) + + . reduce 34 + + +state 116 + direct_declarator : '(' . declarator ')' (82) + direct_abs_declarator : '(' . abs_declarator ')' (108) + direct_abs_declarator : '(' . parameter_type_list ')' (113) + direct_abs_declarator : '(' . ')' (114) + + '(' shift 116 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 6 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_BRACKETS shift 117 + ')' shift 132 + . error + + decl_specifiers goto 99 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + declarator goto 57 + direct_declarator goto 42 + abs_declarator goto 133 + direct_abs_declarator goto 120 + parameter_type_list goto 134 + parameter_list goto 101 + parameter_declaration goto 102 + struct_or_union goto 43 + pointer goto 121 + any_id goto 45 + identifier_or_ref goto 46 + enumeration goto 47 + + +state 117 + direct_abs_declarator : T_BRACKETS . (110) + + . reduce 110 + + +state 118 + parameter_declaration : decl_specifiers declarator . (96) + + . reduce 96 + + +state 119 + parameter_declaration : decl_specifiers abs_declarator . (97) + + . reduce 97 + + +state 120 + abs_declarator : direct_abs_declarator . (107) + direct_abs_declarator : direct_abs_declarator . T_BRACKETS (109) + direct_abs_declarator : direct_abs_declarator . '(' parameter_type_list ')' (111) + direct_abs_declarator : direct_abs_declarator . '(' ')' (112) + + '(' shift 135 + T_BRACKETS shift 136 + ',' reduce 107 + ')' reduce 107 + + +state 121 + declarator : pointer . direct_declarator (79) + abs_declarator : pointer . (105) + abs_declarator : pointer . direct_abs_declarator (106) + + '(' shift 116 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + T_BRACKETS shift 117 + ',' reduce 105 + ')' reduce 105 + + direct_declarator goto 78 + direct_abs_declarator goto 137 + any_id goto 45 + identifier_or_ref goto 46 + + +state 122 + direct_declarator : direct_declarator '(' parameter_type_list ')' . (84) + + . reduce 84 + + +state 123 + parameter_type_list : parameter_list ',' . T_ELLIPSIS (93) + parameter_list : parameter_list ',' . parameter_declaration (95) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + T_ELLIPSIS shift 138 + . error + + decl_specifiers goto 99 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + parameter_declaration goto 139 + struct_or_union goto 43 + enumeration goto 47 + + +state 124 + direct_declarator : direct_declarator '(' opt_identifier_list ')' . (85) + + . reduce 85 + + +state 125 + identifier_list : identifier_list ',' . any_id (102) + + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + . error + + any_id goto 140 + + +state 126 + declarator_list : declarator . (23) + + . reduce 23 + + +state 127 + declaration : any_typedef decl_specifiers $$1 opt_declarator_list . ';' (18) + + ';' shift 141 + . error + + +state 128 + opt_declarator_list : declarator_list . (22) + declarator_list : declarator_list . ',' declarator (24) + + ',' shift 142 + ';' reduce 22 + + +state 129 + init_declarator : declarator '=' $$5 T_INITIALIZER . (72) + + . reduce 72 + + +state 130 + function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE . $$3 T_MATCHRBRACE (27) + $$3 : . (26) + + . reduce 26 + + $$3 goto 143 + + +state 131 + function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE . (29) + + . reduce 29 + + +state 132 + direct_abs_declarator : '(' ')' . (114) + + . reduce 114 + + +state 133 + direct_abs_declarator : '(' abs_declarator . ')' (108) + + ')' shift 144 + . error + + +state 134 + direct_abs_declarator : '(' parameter_type_list . ')' (113) + + ')' shift 145 + . error + + +state 135 + direct_abs_declarator : direct_abs_declarator '(' . parameter_type_list ')' (111) + direct_abs_declarator : direct_abs_declarator '(' . ')' (112) + + T_TYPEDEF_NAME shift 82 + T_DEFINE_NAME shift 7 + T_AUTO shift 8 + T_EXTERN shift 65 + T_REGISTER shift 10 + T_STATIC shift 11 + T_INLINE shift 13 + T_EXTENSION shift 66 + T_CHAR shift 15 + T_DOUBLE shift 16 + T_FLOAT shift 17 + T_INT shift 18 + T_VOID shift 19 + T_LONG shift 20 + T_SHORT shift 21 + T_SIGNED shift 22 + T_UNSIGNED shift 23 + T_ENUM shift 24 + T_STRUCT shift 25 + T_UNION shift 26 + T_Bool shift 27 + T_Complex shift 28 + T_Imaginary shift 29 + T_TYPE_QUALIFIER shift 30 + ')' shift 146 + . error + + decl_specifiers goto 99 + decl_specifier goto 35 + storage_class goto 36 + type_specifier goto 37 + type_qualifier goto 38 + struct_or_union_specifier goto 39 + enum_specifier goto 40 + parameter_type_list goto 147 + parameter_list goto 101 + parameter_declaration goto 102 + struct_or_union goto 43 + enumeration goto 47 + + +state 136 + direct_abs_declarator : direct_abs_declarator T_BRACKETS . (109) + + . reduce 109 + + +state 137 + abs_declarator : pointer direct_abs_declarator . (106) + direct_abs_declarator : direct_abs_declarator . T_BRACKETS (109) + direct_abs_declarator : direct_abs_declarator . '(' parameter_type_list ')' (111) + direct_abs_declarator : direct_abs_declarator . '(' ')' (112) + + '(' shift 135 + T_BRACKETS shift 136 + ',' reduce 106 + ')' reduce 106 + + +state 138 + parameter_type_list : parameter_list ',' T_ELLIPSIS . (93) + + . reduce 93 + + +state 139 + parameter_list : parameter_list ',' parameter_declaration . (95) + + . reduce 95 + + +state 140 + identifier_list : identifier_list ',' any_id . (102) + + . reduce 102 + + +state 141 + declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';' . (18) + + . reduce 18 + + +state 142 + declarator_list : declarator_list ',' . declarator (24) + + '(' shift 2 + '*' shift 3 + '&' shift 4 + T_IDENTIFIER shift 5 + T_TYPEDEF_NAME shift 56 + . error + + declarator goto 148 + direct_declarator goto 42 + pointer goto 44 + any_id goto 45 + identifier_or_ref goto 46 + + +state 143 + function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 . T_MATCHRBRACE (27) + + T_MATCHRBRACE shift 149 + . error + + +state 144 + direct_abs_declarator : '(' abs_declarator ')' . (108) + + . reduce 108 + + +state 145 + direct_abs_declarator : '(' parameter_type_list ')' . (113) + + . reduce 113 + + +state 146 + direct_abs_declarator : direct_abs_declarator '(' ')' . (112) + + . reduce 112 + + +state 147 + direct_abs_declarator : direct_abs_declarator '(' parameter_type_list . ')' (111) + + ')' shift 150 + . error + + +state 148 + declarator_list : declarator_list ',' declarator . (24) + + . reduce 24 + + +state 149 + function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE . (27) + + . reduce 27 + + +state 150 + direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')' . (111) + + . reduce 111 + + +State 6 contains 29 reduce/reduce conflicts. +State 83 contains 1 shift/reduce conflict. + + +44 terminals, 43 nonterminals +115 grammar rules, 151 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 40 '(' + 3 42 '*' + 4 38 '&' + 5 257 T_IDENTIFIER + 6 258 T_TYPEDEF_NAME + 7 259 T_DEFINE_NAME + 8 260 T_AUTO + 9 261 T_EXTERN + 10 262 T_REGISTER + 11 263 T_STATIC + 12 264 T_TYPEDEF + 13 265 T_INLINE + 14 266 T_EXTENSION + 15 267 T_CHAR + 16 268 T_DOUBLE + 17 269 T_FLOAT + 18 270 T_INT + 19 271 T_VOID + 20 272 T_LONG + 21 273 T_SHORT + 22 274 T_SIGNED + 23 275 T_UNSIGNED + 24 276 T_ENUM + 25 277 T_STRUCT + 26 278 T_UNION + 27 279 T_Bool + 28 280 T_Complex + 29 281 T_Imaginary + 30 282 T_TYPE_QUALIFIER + 31 283 T_BRACKETS + 32 284 T_LBRACE + 33 285 T_MATCHRBRACE + 34 286 T_ELLIPSIS + 35 287 T_INITIALIZER + 36 288 T_STRING_LITERAL + 37 289 T_ASM + 38 290 T_ASMARG + 39 291 T_VA_DCL + 40 59 ';' + 41 44 ',' + 42 61 '=' + 43 41 ')' + 44 292 $accept + 45 293 program + 46 294 decl_specifiers + 47 295 decl_specifier + 48 296 storage_class + 49 297 type_specifier + 50 298 type_qualifier + 51 299 struct_or_union_specifier + 52 300 enum_specifier + 53 301 init_declarator_list + 54 302 init_declarator + 55 303 declarator + 56 304 direct_declarator + 57 305 abs_declarator + 58 306 direct_abs_declarator + 59 307 parameter_type_list + 60 308 parameter_list + 61 309 parameter_declaration + 62 310 opt_identifier_list + 63 311 identifier_list + 64 312 struct_or_union + 65 313 pointer + 66 314 opt_type_qualifiers + 67 315 type_qualifier_list + 68 316 any_id + 69 317 identifier_or_ref + 70 318 enumeration + 71 319 translation_unit + 72 320 external_declaration + 73 321 declaration + 74 322 function_definition + 75 323 linkage_specification + 76 324 braces + 77 325 any_typedef + 78 326 opt_declarator_list + 79 327 $$1 + 80 328 declarator_list + 81 329 opt_declaration_list + 82 330 $$2 + 83 331 $$3 + 84 332 $$4 + 85 333 declaration_list + 86 334 $$5 diff --git a/contrib/byacc/test/btyacc/grammar.tab.c b/contrib/byacc/test/btyacc/grammar.tab.c new file mode 100644 index 000000000..fc5270a54 --- /dev/null +++ b/contrib/byacc/test/btyacc/grammar.tab.c @@ -0,0 +1,2813 @@ +/* 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 grammar_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex grammar_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror grammar_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar grammar_char +#endif /* yychar */ + +#ifndef yyval +#define yyval grammar_val +#endif /* yyval */ + +#ifndef yylval +#define yylval grammar_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug grammar_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs grammar_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag grammar_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs grammar_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen grammar_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred grammar_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos grammar_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto grammar_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex grammar_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex grammar_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex grammar_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable grammar_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck grammar_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname grammar_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule grammar_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex grammar_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable grammar_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "grammar_" + +#define YYPURE 0 + +#line 9 "grammar.y" +#ifdef YYBISON +#include +#define YYSTYPE_IS_DECLARED +#define yyerror yaccError +#endif + +#if defined(YYBISON) || !defined(YYBYACC) +static void yyerror(const char *s); +#endif +#line 81 "grammar.y" +#include +#include +#include + +#define OPT_LINTLIBRARY 1 + +#ifndef TRUE +#define TRUE (1) +#endif + +#ifndef FALSE +#define FALSE (0) +#endif + +/* #include "cproto.h" */ +#define MAX_TEXT_SIZE 1024 + +/* Prototype styles */ +#if OPT_LINTLIBRARY +#define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */ +#define PROTO_LINTLIBRARY -1 /* form lint-library source */ +#endif +#define PROTO_NONE 0 /* do not output any prototypes */ +#define PROTO_TRADITIONAL 1 /* comment out parameters */ +#define PROTO_ABSTRACT 2 /* comment out parameter names */ +#define PROTO_ANSI 3 /* ANSI C prototype */ + +typedef int PrototypeStyle; + +typedef char boolean; + +extern boolean types_out; +extern PrototypeStyle proto_style; + +#define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB) +#define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY) +#define lintLibrary() (knrLintLibrary() || ansiLintLibrary()) + +#if OPT_LINTLIBRARY +#define FUNC_UNKNOWN -1 /* unspecified */ +#else +#define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */ +#endif +#define FUNC_NONE 0 /* not a function definition */ +#define FUNC_TRADITIONAL 1 /* traditional style */ +#define FUNC_ANSI 2 /* ANSI style */ +#define FUNC_BOTH 3 /* both styles */ + +typedef int FuncDefStyle; + +/* Source file text */ +typedef struct text { + char text[MAX_TEXT_SIZE]; /* source text */ + long begin; /* offset in temporary file */ +} Text; + +/* Declaration specifier flags */ +#define DS_NONE 0 /* default */ +#define DS_EXTERN 1 /* contains "extern" specifier */ +#define DS_STATIC 2 /* contains "static" specifier */ +#define DS_CHAR 4 /* contains "char" type specifier */ +#define DS_SHORT 8 /* contains "short" type specifier */ +#define DS_FLOAT 16 /* contains "float" type specifier */ +#define DS_INLINE 32 /* contains "inline" specifier */ +#define DS_JUNK 64 /* we're not interested in this declaration */ + +/* This structure stores information about a declaration specifier. */ +typedef struct decl_spec { + unsigned short flags; /* flags defined above */ + char *text; /* source text */ + long begin; /* offset in temporary file */ +} DeclSpec; + +/* This is a list of function parameters. */ +typedef struct _ParameterList { + struct parameter *first; /* pointer to first parameter in list */ + struct parameter *last; /* pointer to last parameter in list */ + long begin_comment; /* begin offset of comment */ + long end_comment; /* end offset of comment */ + char *comment; /* comment at start of parameter list */ +} ParameterList; + +/* This structure stores information about a declarator. */ +typedef struct _Declarator { + char *name; /* name of variable or function */ + char *text; /* source text */ + long begin; /* offset in temporary file */ + long begin_comment; /* begin offset of comment */ + long end_comment; /* end offset of comment */ + FuncDefStyle func_def; /* style of function definition */ + ParameterList params; /* function parameters */ + boolean pointer; /* TRUE if it declares a pointer */ + struct _Declarator *head; /* head function declarator */ + struct _Declarator *func_stack; /* stack of function declarators */ + struct _Declarator *next; /* next declarator in list */ +} Declarator; + +/* This structure stores information about a function parameter. */ +typedef struct parameter { + struct parameter *next; /* next parameter in list */ + DeclSpec decl_spec; + Declarator *declarator; + char *comment; /* comment following the parameter */ +} Parameter; + +/* This is a list of declarators. */ +typedef struct declarator_list { + Declarator *first; /* pointer to first declarator in list */ + Declarator *last; /* pointer to last declarator in list */ +} DeclaratorList; + +/* #include "symbol.h" */ +typedef struct symbol { + struct symbol *next; /* next symbol in list */ + char *name; /* name of symbol */ + char *value; /* value of symbol (for defines) */ + short flags; /* symbol attributes */ +} Symbol; + +/* parser stack entry type */ +typedef union { + Text text; + DeclSpec decl_spec; + Parameter *parameter; + ParameterList param_list; + Declarator *declarator; + DeclaratorList decl_list; +} YYSTYPE; + +/* The hash table length should be a prime number. */ +#define SYM_MAX_HASH 251 + +typedef struct symbol_table { + Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */ +} SymbolTable; + +extern SymbolTable *new_symbol_table /* Create symbol table */ + (void); +extern void free_symbol_table /* Destroy symbol table */ + (SymbolTable *s); +extern Symbol *find_symbol /* Lookup symbol name */ + (SymbolTable *s, const char *n); +extern Symbol *new_symbol /* Define new symbol */ + (SymbolTable *s, const char *n, const char *v, int f); + +/* #include "semantic.h" */ +extern void new_decl_spec (DeclSpec *, const char *, long, int); +extern void free_decl_spec (DeclSpec *); +extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *); +extern void check_untagged (DeclSpec *); +extern Declarator *new_declarator (const char *, const char *, long); +extern void free_declarator (Declarator *); +extern void new_decl_list (DeclaratorList *, Declarator *); +extern void free_decl_list (DeclaratorList *); +extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *); +extern Parameter *new_parameter (DeclSpec *, Declarator *); +extern void free_parameter (Parameter *); +extern void new_param_list (ParameterList *, Parameter *); +extern void free_param_list (ParameterList *); +extern void add_param_list (ParameterList *, ParameterList *, Parameter *); +extern void new_ident_list (ParameterList *); +extern void add_ident_list (ParameterList *, ParameterList *, const char *); +extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *); +extern void gen_declarations (DeclSpec *, DeclaratorList *); +extern void gen_prototype (DeclSpec *, Declarator *); +extern void gen_func_declarator (Declarator *); +extern void gen_func_definition (DeclSpec *, Declarator *); + +extern void init_parser (void); +extern void process_file (FILE *infile, char *name); +extern char *cur_text (void); +extern char *cur_file_name (void); +extern char *implied_typedef (void); +extern void include_file (char *name, int convert); +extern char *supply_parm (int count); +extern char *xstrdup (const char *); +extern int already_declared (char *name); +extern int is_actual_func (Declarator *d); +extern int lint_ellipsis (Parameter *p); +extern int want_typedef (void); +extern void begin_tracking (void); +extern void begin_typedef (void); +extern void copy_typedef (char *s); +extern void ellipsis_varargs (Declarator *d); +extern void end_typedef (void); +extern void flush_varargs (void); +extern void fmt_library (int code); +extern void imply_typedef (const char *s); +extern void indent (FILE *outf); +extern void put_blankline (FILE *outf); +extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator); +extern void put_char (FILE *outf, int c); +extern void put_error (void); +extern void put_newline (FILE *outf); +extern void put_padded (FILE *outf, const char *s); +extern void put_string (FILE *outf, const char *s); +extern void track_in (void); + +extern boolean file_comments; +extern FuncDefStyle func_style; +extern char base_file[]; + +extern int yylex (void); + +/* declaration specifier attributes for the typedef statement currently being + * scanned + */ +static int cur_decl_spec_flags; + +/* pointer to parameter list for the current function definition */ +static ParameterList *func_params; + +/* A parser semantic action sets this pointer to the current declarator in + * a function parameter declaration in order to catch any comments following + * the parameter declaration on the same line. If the lexer scans a comment + * and is not NULL, then the comment is attached to the + * declarator. To ignore subsequent comments, the lexer sets this to NULL + * after scanning a comment or end of line. + */ +static Declarator *cur_declarator; + +/* temporary string buffer */ +static char buf[MAX_TEXT_SIZE]; + +/* table of typedef names */ +static SymbolTable *typedef_names; + +/* table of define names */ +static SymbolTable *define_names; + +/* table of type qualifiers */ +static SymbolTable *type_qualifiers; + +/* information about the current input file */ +typedef struct { + char *base_name; /* base input file name */ + char *file_name; /* current file name */ + FILE *file; /* input file */ + unsigned line_num; /* current line number in input file */ + FILE *tmp_file; /* temporary file */ + long begin_comment; /* tmp file offset after last written ) or ; */ + long end_comment; /* tmp file offset after last comment */ + boolean convert; /* if TRUE, convert function definitions */ + boolean changed; /* TRUE if conversion done in this file */ +} IncludeStack; + +static IncludeStack *cur_file; /* current input file */ + +/* #include "yyerror.c" */ + +static int haveAnsiParam (void); + + +/* Flags to enable us to find if a procedure returns a value. + */ +static int return_val; /* nonzero on BRACES iff return-expression found */ + +static const char * +dft_decl_spec (void) +{ + return (lintLibrary() && !return_val) ? "void" : "int"; +} + +static int +haveAnsiParam (void) +{ + Parameter *p; + if (func_params != 0) { + for (p = func_params->first; p != 0; p = p->next) { + if (p->declarator->func_def == FUNC_ANSI) { + return TRUE; + } + } + } + return FALSE; +} +#line 408 "grammar.tab.c" + +/* 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 T_IDENTIFIER 257 +#define T_TYPEDEF_NAME 258 +#define T_DEFINE_NAME 259 +#define T_AUTO 260 +#define T_EXTERN 261 +#define T_REGISTER 262 +#define T_STATIC 263 +#define T_TYPEDEF 264 +#define T_INLINE 265 +#define T_EXTENSION 266 +#define T_CHAR 267 +#define T_DOUBLE 268 +#define T_FLOAT 269 +#define T_INT 270 +#define T_VOID 271 +#define T_LONG 272 +#define T_SHORT 273 +#define T_SIGNED 274 +#define T_UNSIGNED 275 +#define T_ENUM 276 +#define T_STRUCT 277 +#define T_UNION 278 +#define T_Bool 279 +#define T_Complex 280 +#define T_Imaginary 281 +#define T_TYPE_QUALIFIER 282 +#define T_BRACKETS 283 +#define T_LBRACE 284 +#define T_MATCHRBRACE 285 +#define T_ELLIPSIS 286 +#define T_INITIALIZER 287 +#define T_STRING_LITERAL 288 +#define T_ASM 289 +#define T_ASMARG 290 +#define T_VA_DCL 291 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT grammar_lhs[] = { -1, + 0, 0, 26, 26, 27, 27, 27, 27, 27, 27, + 27, 31, 30, 30, 28, 28, 34, 28, 32, 32, + 33, 33, 35, 35, 37, 38, 29, 39, 29, 36, + 36, 36, 40, 40, 1, 1, 2, 2, 2, 3, + 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 6, 6, 6, 19, 19, 8, 8, 9, + 41, 9, 7, 7, 7, 25, 23, 23, 10, 10, + 11, 11, 11, 11, 11, 20, 20, 21, 21, 22, + 22, 14, 14, 15, 15, 16, 16, 16, 17, 17, + 18, 18, 24, 24, 12, 12, 12, 13, 13, 13, + 13, 13, 13, 13, +}; +static const YYINT grammar_len[] = { 2, + 0, 1, 1, 2, 1, 1, 1, 1, 3, 2, + 2, 2, 3, 3, 2, 3, 0, 5, 2, 1, + 0, 1, 1, 3, 0, 0, 7, 0, 5, 0, + 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 2, 2, 1, 1, 1, 3, 1, + 0, 4, 3, 2, 2, 1, 1, 1, 2, 1, + 1, 3, 2, 4, 4, 2, 3, 0, 1, 1, + 2, 1, 3, 1, 3, 2, 2, 1, 0, 1, + 1, 3, 1, 2, 1, 2, 1, 3, 2, 1, + 4, 3, 3, 2, +}; +static const YYINT grammar_defred[] = { 0, + 0, 0, 0, 0, 77, 0, 62, 40, 0, 42, + 43, 20, 44, 0, 46, 47, 48, 49, 54, 50, + 51, 52, 53, 76, 66, 67, 55, 56, 57, 61, + 0, 7, 0, 0, 35, 37, 38, 39, 59, 60, + 28, 0, 0, 0, 103, 81, 0, 0, 3, 5, + 6, 8, 0, 10, 11, 78, 0, 90, 0, 0, + 104, 0, 19, 0, 41, 45, 15, 36, 0, 68, + 0, 0, 0, 83, 0, 0, 64, 0, 0, 74, + 4, 58, 0, 82, 87, 91, 0, 14, 13, 9, + 16, 0, 71, 0, 31, 33, 0, 0, 0, 0, + 0, 94, 0, 0, 101, 12, 63, 73, 0, 0, + 69, 0, 0, 0, 34, 0, 110, 96, 97, 0, + 0, 84, 0, 85, 0, 23, 0, 0, 72, 26, + 29, 114, 0, 0, 0, 109, 0, 93, 95, 102, + 18, 0, 0, 108, 113, 112, 0, 24, 27, 111, +}; +static const YYINT grammar_stos[] = { 0, + 256, 40, 42, 38, 257, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, + 289, 59, 293, 294, 295, 296, 297, 298, 299, 300, + 303, 304, 312, 313, 316, 317, 318, 319, 320, 321, + 322, 323, 325, 285, 59, 258, 303, 298, 314, 315, + 316, 288, 264, 290, 261, 266, 59, 295, 301, 302, + 303, 332, 40, 283, 284, 316, 324, 304, 316, 324, + 320, 258, 294, 41, 313, 298, 294, 321, 324, 59, + 59, 44, 61, 330, 291, 321, 329, 333, 294, 307, + 308, 309, 310, 311, 316, 285, 324, 324, 327, 303, + 302, 334, 329, 284, 321, 40, 283, 303, 305, 306, + 313, 41, 44, 41, 44, 303, 326, 328, 287, 284, + 285, 41, 305, 307, 40, 283, 306, 286, 309, 316, + 59, 44, 331, 41, 41, 41, 307, 303, 285, 41, +}; +static const YYINT grammar_dgoto[] = { 33, + 87, 35, 36, 37, 38, 39, 40, 69, 70, 41, + 42, 119, 120, 100, 101, 102, 103, 104, 43, 44, + 59, 60, 45, 46, 47, 48, 49, 50, 51, 52, + 77, 53, 127, 109, 128, 97, 94, 143, 72, 98, + 112, +}; +static const YYINT grammar_sindex[] = { -2, + -3, 27, -239, -177, 0, 0, 0, 0, -274, 0, + 0, 0, 0, -246, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -266, 0, 0, 455, 0, 0, 0, 0, 0, 0, + 0, -35, -245, 128, 0, 0, -245, -2, 0, 0, + 0, 0, 642, 0, 0, 0, -15, 0, -12, -239, + 0, 590, 0, -27, 0, 0, 0, 0, -10, 0, + -11, 534, -72, 0, -237, -232, 0, -35, -232, 0, + 0, 0, 642, 0, 0, 0, 455, 0, 0, 0, + 0, 27, 0, 534, 0, 0, -222, 617, 209, 34, + 39, 0, 44, 42, 0, 0, 0, 0, 27, -11, + 0, -200, -196, -195, 0, 174, 0, 0, 0, -33, + 243, 0, 561, 0, -177, 0, 33, 49, 0, 0, + 0, 0, 53, 55, 417, 0, -33, 0, 0, 0, + 0, 27, -188, 0, 0, 0, 57, 0, 0, 0, +}; +static const YYINT grammar_rindex[] = { 99, + 0, 0, 275, 0, 0, -38, 0, 0, 481, 0, + 0, 0, 0, 509, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 30, 0, 0, 0, 0, 0, 101, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 343, 309, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 98, -182, 62, 0, 0, 133, 0, 64, 379, 0, + 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -182, 0, 0, 0, -180, -19, 0, + 65, 0, 0, 68, 0, 0, 0, 0, 51, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -13, + 19, 0, 0, 0, 0, 0, 0, 52, 0, 0, + 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +#if YYBTYACC +static const YYINT grammar_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, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 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 grammar_gindex[] = { 0, + 11, -17, 0, 0, 13, 0, 0, 0, 20, 8, + -43, -1, -8, -89, 0, -9, 0, 0, 0, -44, + 0, 0, 4, 0, 0, 0, 70, -53, 0, 0, + -18, 0, 0, 0, 0, 22, 0, 0, 0, 0, + 0, +}; +#define YYTABLESIZE 924 +static const YYINT grammar_table[] = { 58, + 78, 58, 58, 58, 73, 58, 135, 61, 88, 57, + 34, 5, 56, 62, 85, 58, 68, 63, 96, 7, + 58, 98, 78, 64, 98, 84, 134, 107, 80, 3, + 107, 90, 17, 92, 17, 4, 17, 2, 75, 3, + 96, 71, 30, 89, 115, 147, 76, 106, 91, 93, + 79, 75, 70, 17, 121, 55, 32, 107, 34, 105, + 108, 114, 105, 83, 4, 68, 2, 70, 3, 68, + 80, 121, 86, 80, 122, 106, 105, 78, 106, 5, + 56, 68, 123, 99, 124, 125, 129, 130, 80, 131, + 80, 141, 142, 144, 110, 145, 149, 150, 1, 110, + 2, 30, 99, 32, 79, 92, 118, 79, 100, 21, + 22, 111, 137, 139, 133, 113, 126, 81, 0, 0, + 0, 0, 79, 57, 79, 0, 99, 0, 140, 0, + 0, 0, 0, 99, 0, 0, 0, 0, 0, 0, + 0, 70, 0, 0, 0, 99, 0, 0, 0, 148, + 0, 0, 0, 0, 0, 0, 70, 0, 0, 0, + 0, 0, 0, 0, 0, 4, 0, 2, 0, 0, + 65, 0, 65, 65, 65, 0, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 6, 7, 8, 65, 10, + 11, 65, 13, 66, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 0, 4, 0, 116, 132, 3, 0, 0, 58, 58, + 58, 58, 58, 58, 58, 78, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 78, 4, 74, 116, 136, + 3, 17, 78, 1, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 4, 54, 116, 5, 56, 0, 31, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 88, 80, 88, 88, 88, 0, 88, 0, + 80, 79, 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 89, 79, 89, 89, + 89, 0, 89, 0, 79, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 86, 25, 86, 86, 5, 56, 86, 0, 25, 65, + 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 75, 0, 75, 75, + 75, 0, 75, 0, 0, 0, 0, 0, 0, 0, + 5, 6, 7, 8, 65, 10, 11, 75, 13, 66, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 117, 146, 0, 0, + 0, 0, 0, 0, 0, 5, 6, 7, 8, 65, + 10, 11, 0, 13, 66, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 117, 4, 0, 2, 0, 3, 0, 0, 5, + 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 67, 0, 0, 0, 0, 41, 0, + 41, 0, 41, 0, 0, 117, 0, 0, 0, 0, + 0, 88, 88, 0, 0, 0, 0, 0, 0, 41, + 0, 0, 0, 0, 0, 0, 45, 0, 45, 0, + 45, 0, 0, 0, 0, 0, 0, 88, 0, 0, + 0, 0, 0, 0, 0, 89, 89, 45, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 89, 0, 0, 0, 0, 0, 0, 0, 86, + 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 75, 75, 75, 75, 75, + 75, 75, 0, 75, 75, 75, 75, 75, 75, 75, + 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, + 75, 75, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 82, 7, 8, 65, 10, 11, + 0, 13, 66, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 6, 7, 8, 65, 10, 11, 0, 13, + 66, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 41, 41, 41, + 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 0, 0, 45, 45, 45, 45, 45, + 45, 45, 0, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 82, 7, 8, 65, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 0, 0, 82, 7, + 8, 65, 10, 11, 95, 13, 66, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 0, 0, 0, 138, 82, 7, 8, + 65, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 0, 75, 82, 7, 8, 65, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 82, + 7, 8, 65, 10, 11, 0, 13, 66, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, +}; +static const YYINT grammar_check[] = { 38, + 44, 40, 41, 42, 40, 44, 40, 4, 62, 2, + 0, 257, 258, 288, 59, 3, 34, 264, 72, 259, + 59, 41, 61, 290, 44, 41, 116, 41, 47, 42, + 44, 59, 38, 44, 40, 38, 42, 40, 284, 42, + 94, 34, 282, 62, 98, 135, 43, 285, 59, 61, + 47, 284, 44, 59, 99, 59, 59, 76, 48, 41, + 79, 284, 44, 53, 38, 83, 40, 59, 42, 87, + 41, 116, 60, 44, 41, 41, 73, 121, 44, 257, + 258, 99, 44, 73, 41, 44, 287, 284, 59, 285, + 61, 59, 44, 41, 87, 41, 285, 41, 0, 92, + 0, 284, 41, 284, 41, 41, 99, 44, 41, 59, + 59, 92, 121, 123, 116, 94, 109, 48, -1, -1, + -1, -1, 59, 116, 61, -1, 116, -1, 125, -1, + -1, -1, -1, 123, -1, -1, -1, -1, -1, -1, + -1, 44, -1, -1, -1, 135, -1, -1, -1, 142, + -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, + -1, -1, -1, -1, -1, 38, -1, 40, -1, -1, + 38, -1, 40, 41, 42, -1, 44, -1, -1, -1, + -1, -1, -1, -1, 257, 258, 259, 260, 261, 262, + 263, 59, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, + -1, 38, -1, 40, 41, 42, -1, -1, 257, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, 38, 283, 40, 283, + 42, 257, 291, 256, 257, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, + 38, 285, 40, 257, 258, -1, 289, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, + 281, 282, 38, 284, 40, 41, 42, -1, 44, -1, + 291, 258, 259, 260, 261, 262, 263, 264, 265, 266, + 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 38, 284, 40, 41, + 42, -1, 44, -1, 291, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, + 38, 284, 40, 41, 257, 258, 44, -1, 291, 257, + 258, 259, 260, 261, 262, 263, -1, 265, 266, 267, + 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, + 278, 279, 280, 281, 282, 283, 38, -1, 40, 41, + 42, -1, 44, -1, -1, -1, -1, -1, -1, -1, + 257, 258, 259, 260, 261, 262, 263, 59, 265, 266, + 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 41, -1, -1, + -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, + 262, 263, -1, 265, 266, 267, 268, 269, 270, 271, + 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 38, -1, 40, -1, 42, -1, -1, 257, + 258, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 59, -1, -1, -1, -1, 38, -1, + 40, -1, 42, -1, -1, 283, -1, -1, -1, -1, + -1, 257, 258, -1, -1, -1, -1, -1, -1, 59, + -1, -1, -1, -1, -1, -1, 38, -1, 40, -1, + 42, -1, -1, -1, -1, -1, -1, 283, -1, -1, + -1, -1, -1, -1, -1, 257, 258, 59, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 283, -1, -1, -1, -1, -1, -1, -1, 257, + 258, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 283, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, + 262, 263, -1, 265, 266, 267, 268, 269, 270, 271, + 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 258, 259, 260, 261, 262, 263, + -1, 265, 266, 267, 268, 269, 270, 271, 272, 273, + 274, 275, 276, 277, 278, 279, 280, 281, 282, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 257, 258, 259, 260, 261, 262, 263, -1, 265, + 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, + 276, 277, 278, 279, 280, 281, 282, 257, 258, 259, + 260, 261, 262, 263, -1, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + 280, 281, 282, -1, -1, 257, 258, 259, 260, 261, + 262, 263, -1, 265, 266, 267, 268, 269, 270, 271, + 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 258, 259, 260, 261, 262, 263, 264, 265, 266, + 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 277, 278, 279, 280, 281, 282, -1, -1, 258, 259, + 260, 261, 262, 263, 291, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + 280, 281, 282, -1, -1, -1, 286, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, + 281, 282, -1, 284, 258, 259, 260, 261, 262, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 258, + 259, 260, 261, 262, 263, -1, 265, 266, 267, 268, + 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, + 279, 280, 281, 282, +}; +#define YYFINAL 33 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 291 +#define YYUNDFTOKEN 335 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const grammar_name[] = { + +"$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, +0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,"'='",0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,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", +"T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN", +"T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR", +"T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED", +"T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary", +"T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS", +"T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL","$accept", +"program","decl_specifiers","decl_specifier","storage_class","type_specifier", +"type_qualifier","struct_or_union_specifier","enum_specifier", +"init_declarator_list","init_declarator","declarator","direct_declarator", +"abs_declarator","direct_abs_declarator","parameter_type_list","parameter_list", +"parameter_declaration","opt_identifier_list","identifier_list", +"struct_or_union","pointer","opt_type_qualifiers","type_qualifier_list", +"any_id","identifier_or_ref","enumeration","translation_unit", +"external_declaration","declaration","function_definition", +"linkage_specification","braces","any_typedef","opt_declarator_list","$$1", +"declarator_list","opt_declaration_list","$$2","$$3","$$4","declaration_list", +"$$5","illegal-symbol", +}; +static const char *const grammar_rule[] = { +"$accept : program", +"program :", +"program : translation_unit", +"translation_unit : external_declaration", +"translation_unit : translation_unit external_declaration", +"external_declaration : declaration", +"external_declaration : function_definition", +"external_declaration : ';'", +"external_declaration : linkage_specification", +"external_declaration : T_ASM T_ASMARG ';'", +"external_declaration : error T_MATCHRBRACE", +"external_declaration : error ';'", +"braces : T_LBRACE T_MATCHRBRACE", +"linkage_specification : T_EXTERN T_STRING_LITERAL braces", +"linkage_specification : T_EXTERN T_STRING_LITERAL declaration", +"declaration : decl_specifiers ';'", +"declaration : decl_specifiers init_declarator_list ';'", +"$$1 :", +"declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'", +"any_typedef : T_EXTENSION T_TYPEDEF", +"any_typedef : T_TYPEDEF", +"opt_declarator_list :", +"opt_declarator_list : declarator_list", +"declarator_list : declarator", +"declarator_list : declarator_list ',' declarator", +"$$2 :", +"$$3 :", +"function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE", +"$$4 :", +"function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE", +"opt_declaration_list :", +"opt_declaration_list : T_VA_DCL", +"opt_declaration_list : declaration_list", +"declaration_list : declaration", +"declaration_list : declaration_list declaration", +"decl_specifiers : decl_specifier", +"decl_specifiers : decl_specifiers decl_specifier", +"decl_specifier : storage_class", +"decl_specifier : type_specifier", +"decl_specifier : type_qualifier", +"storage_class : T_AUTO", +"storage_class : T_EXTERN", +"storage_class : T_REGISTER", +"storage_class : T_STATIC", +"storage_class : T_INLINE", +"storage_class : T_EXTENSION", +"type_specifier : T_CHAR", +"type_specifier : T_DOUBLE", +"type_specifier : T_FLOAT", +"type_specifier : T_INT", +"type_specifier : T_LONG", +"type_specifier : T_SHORT", +"type_specifier : T_SIGNED", +"type_specifier : T_UNSIGNED", +"type_specifier : T_VOID", +"type_specifier : T_Bool", +"type_specifier : T_Complex", +"type_specifier : T_Imaginary", +"type_specifier : T_TYPEDEF_NAME", +"type_specifier : struct_or_union_specifier", +"type_specifier : enum_specifier", +"type_qualifier : T_TYPE_QUALIFIER", +"type_qualifier : T_DEFINE_NAME", +"struct_or_union_specifier : struct_or_union any_id braces", +"struct_or_union_specifier : struct_or_union braces", +"struct_or_union_specifier : struct_or_union any_id", +"struct_or_union : T_STRUCT", +"struct_or_union : T_UNION", +"init_declarator_list : init_declarator", +"init_declarator_list : init_declarator_list ',' init_declarator", +"init_declarator : declarator", +"$$5 :", +"init_declarator : declarator '=' $$5 T_INITIALIZER", +"enum_specifier : enumeration any_id braces", +"enum_specifier : enumeration braces", +"enum_specifier : enumeration any_id", +"enumeration : T_ENUM", +"any_id : T_IDENTIFIER", +"any_id : T_TYPEDEF_NAME", +"declarator : pointer direct_declarator", +"declarator : direct_declarator", +"direct_declarator : identifier_or_ref", +"direct_declarator : '(' declarator ')'", +"direct_declarator : direct_declarator T_BRACKETS", +"direct_declarator : direct_declarator '(' parameter_type_list ')'", +"direct_declarator : direct_declarator '(' opt_identifier_list ')'", +"pointer : '*' opt_type_qualifiers", +"pointer : '*' opt_type_qualifiers pointer", +"opt_type_qualifiers :", +"opt_type_qualifiers : type_qualifier_list", +"type_qualifier_list : type_qualifier", +"type_qualifier_list : type_qualifier_list type_qualifier", +"parameter_type_list : parameter_list", +"parameter_type_list : parameter_list ',' T_ELLIPSIS", +"parameter_list : parameter_declaration", +"parameter_list : parameter_list ',' parameter_declaration", +"parameter_declaration : decl_specifiers declarator", +"parameter_declaration : decl_specifiers abs_declarator", +"parameter_declaration : decl_specifiers", +"opt_identifier_list :", +"opt_identifier_list : identifier_list", +"identifier_list : any_id", +"identifier_list : identifier_list ',' any_id", +"identifier_or_ref : any_id", +"identifier_or_ref : '&' any_id", +"abs_declarator : pointer", +"abs_declarator : pointer direct_abs_declarator", +"abs_declarator : direct_abs_declarator", +"direct_abs_declarator : '(' abs_declarator ')'", +"direct_abs_declarator : direct_abs_declarator T_BRACKETS", +"direct_abs_declarator : T_BRACKETS", +"direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'", +"direct_abs_declarator : direct_abs_declarator '(' ')'", +"direct_abs_declarator : '(' parameter_type_list ')'", +"direct_abs_declarator : '(' ')'", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 1014 "grammar.y" + +/* lex.yy.c */ +#define BEGIN yy_start = 1 + 2 * + +#define CPP1 1 +#define INIT1 2 +#define INIT2 3 +#define CURLY 4 +#define LEXYACC 5 +#define ASM 6 +#define CPP_INLINE 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 inc_depth; /* include nesting level */ +static SymbolTable *included_files; /* files already included */ +static int yy_start = 0; /* start state number */ + +#define grammar_error(s) yaccError(s) + +static void +yaccError (const char *msg) +{ + func_params = NULL; + put_error(); /* tell what line we're on, and what file */ + fprintf(stderr, "%s at token '%s'\n", msg, yytext); +} + +/* Initialize the table of type qualifier keywords recognized by the lexical + * analyzer. + */ +void +init_parser (void) +{ + static const char *keywords[] = { + "const", + "restrict", + "volatile", + "interrupt", +#ifdef vms + "noshare", + "readonly", +#endif +#if defined(MSDOS) || defined(OS2) + "__cdecl", + "__export", + "__far", + "__fastcall", + "__fortran", + "__huge", + "__inline", + "__interrupt", + "__loadds", + "__near", + "__pascal", + "__saveregs", + "__segment", + "__stdcall", + "__syscall", + "_cdecl", + "_cs", + "_ds", + "_es", + "_export", + "_far", + "_fastcall", + "_fortran", + "_huge", + "_interrupt", + "_loadds", + "_near", + "_pascal", + "_saveregs", + "_seg", + "_segment", + "_ss", + "cdecl", + "far", + "huge", + "near", + "pascal", +#ifdef OS2 + "__far16", +#endif +#endif +#ifdef __GNUC__ + /* gcc aliases */ + "__builtin_va_arg", + "__builtin_va_list", + "__const", + "__const__", + "__inline", + "__inline__", + "__restrict", + "__restrict__", + "__volatile", + "__volatile__", +#endif + }; + unsigned i; + + /* Initialize type qualifier table. */ + type_qualifiers = new_symbol_table(); + for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) { + new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE); + } +} + +/* Process the C source file. Write function prototypes to the standard + * output. Convert function definitions and write the converted source + * code to a temporary file. + */ +void +process_file (FILE *infile, char *name) +{ + char *s; + + if (strlen(name) > 2) { + s = name + strlen(name) - 2; + if (*s == '.') { + ++s; + if (*s == 'l' || *s == 'y') + BEGIN LEXYACC; +#if defined(MSDOS) || defined(OS2) + if (*s == 'L' || *s == 'Y') + BEGIN LEXYACC; +#endif + } + } + + included_files = new_symbol_table(); + typedef_names = new_symbol_table(); + define_names = new_symbol_table(); + inc_depth = -1; + curly = 0; + ly_count = 0; + func_params = NULL; + yyin = infile; + include_file(strcpy(base_file, name), func_style != FUNC_NONE); + if (file_comments) { +#if OPT_LINTLIBRARY + if (lintLibrary()) { + put_blankline(stdout); + begin_tracking(); + } +#endif + put_string(stdout, "/* "); + put_string(stdout, cur_file_name()); + put_string(stdout, " */\n"); + } + yyparse(); + free_symbol_table(define_names); + free_symbol_table(typedef_names); + free_symbol_table(included_files); +} + +#ifdef NO_LEAKS +void +free_parser(void) +{ + free_symbol_table (type_qualifiers); +#ifdef FLEX_SCANNER + if (yy_current_buffer != 0) + yy_delete_buffer(yy_current_buffer); +#endif +} +#endif +#line 1248 "grammar.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 10: +#line 377 "grammar.y" + { + yyerrok; + } +break; +case 11: +#line 381 "grammar.y" + { + yyerrok; + } +break; +case 13: +#line 392 "grammar.y" + { + /* Provide an empty action here so bison will not complain about + * incompatible types in the default action it normally would + * have generated. + */ + } +break; +case 14: +#line 399 "grammar.y" + { + /* empty */ + } +break; +case 15: +#line 406 "grammar.y" + { +#if OPT_LINTLIBRARY + if (types_out && want_typedef()) { + gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0); + flush_varargs(); + } +#endif + free_decl_spec(&yystack.l_mark[-1].decl_spec); + end_typedef(); + } +break; +case 16: +#line 417 "grammar.y" + { + if (func_params != NULL) { + set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); + } else { + gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); +#if OPT_LINTLIBRARY + flush_varargs(); +#endif + free_decl_list(&yystack.l_mark[-1].decl_list); + } + free_decl_spec(&yystack.l_mark[-2].decl_spec); + end_typedef(); + } +break; +case 17: +#line 431 "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" + { + end_typedef(); + } +break; +case 19: +#line 443 "grammar.y" + { + begin_typedef(); + } +break; +case 20: +#line 447 "grammar.y" + { + begin_typedef(); + } +break; +case 23: +#line 459 "grammar.y" + { + int flags = cur_decl_spec_flags; + + /* If the typedef is a pointer type, then reset the short type + * flags so it does not get promoted. + */ + if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0) + flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); + new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags); + free_declarator(yystack.l_mark[0].declarator); + } +break; +case 24: +#line 471 "grammar.y" + { + int flags = cur_decl_spec_flags; + + if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0) + flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); + new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags); + free_declarator(yystack.l_mark[0].declarator); + } +break; +case 25: +#line 483 "grammar.y" + { + check_untagged(&yystack.l_mark[-1].decl_spec); + if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { + yyerror("syntax error"); + YYERROR; + } + func_params = &(yystack.l_mark[0].declarator->head->params); + func_params->begin_comment = cur_file->begin_comment; + func_params->end_comment = cur_file->end_comment; + } +break; +case 26: +#line 494 "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 + * function pointer), then we must override the deciphered value of + * 'func_def' so that the parameter will be converted. + */ + if (func_style == FUNC_TRADITIONAL + && haveAnsiParam() + && yystack.l_mark[-3].declarator->head->func_def == func_style) { + yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH; + } + + func_params = NULL; + + if (cur_file->convert) + gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator); + gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator); +#if OPT_LINTLIBRARY + flush_varargs(); +#endif + free_decl_spec(&yystack.l_mark[-4].decl_spec); + free_declarator(yystack.l_mark[-3].declarator); + } +break; +case 28: +#line 519 "grammar.y" + { + if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { + yyerror("syntax error"); + YYERROR; + } + func_params = &(yystack.l_mark[0].declarator->head->params); + func_params->begin_comment = cur_file->begin_comment; + func_params->end_comment = cur_file->end_comment; + } +break; +case 29: +#line 529 "grammar.y" + { + DeclSpec decl_spec; + + func_params = NULL; + + new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE); + if (cur_file->convert) + gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator); + gen_prototype(&decl_spec, yystack.l_mark[-4].declarator); +#if OPT_LINTLIBRARY + flush_varargs(); +#endif + free_decl_spec(&decl_spec); + free_declarator(yystack.l_mark[-4].declarator); + } +break; +case 36: +#line 560 "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); + free(yystack.l_mark[0].decl_spec.text); + } +break; +case 40: +#line 575 "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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + 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" + { + Symbol *s; + s = find_symbol(typedef_names, yystack.l_mark[0].text.text); + if (s != NULL) + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags); + } +break; +case 61: +#line 662 "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" + { + /* This rule allows the nonterminal to scan #define + * names as if they were type modifiers. + */ + Symbol *s; + s = find_symbol(define_names, yystack.l_mark[0].text.text); + if (s != NULL) + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags); + } +break; +case 63: +#line 679 "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); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); + } +break; +case 64: +#line 686 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%s {}", 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" + { + (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, 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" + { + imply_typedef(yyval.text.text); + } +break; +case 67: +#line 705 "grammar.y" + { + imply_typedef(yyval.text.text); + } +break; +case 68: +#line 712 "grammar.y" + { + new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); + } +break; +case 69: +#line 716 "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" + { + if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL && + func_style == FUNC_TRADITIONAL && cur_file->convert) { + gen_func_declarator(yystack.l_mark[0].declarator); + fputs(cur_text(), cur_file->tmp_file); + } + cur_declarator = yyval.declarator; + } +break; +case 71: +#line 732 "grammar.y" + { + if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL && + func_style == FUNC_TRADITIONAL && cur_file->convert) { + gen_func_declarator(yystack.l_mark[-1].declarator); + fputs(" =", cur_file->tmp_file); + } + } +break; +case 73: +#line 744 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "enum %s", 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" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%s {}", 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" + { + (void)sprintf(buf, "enum %s", 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" + { + imply_typedef("enum"); + yyval.text = yystack.l_mark[0].text; + } +break; +case 79: +#line 779 "grammar.y" + { + yyval.declarator = yystack.l_mark[0].declarator; + (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-1].text.begin; + yyval.declarator->pointer = TRUE; + } +break; +case 81: +#line 792 "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" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "(%s)", 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" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + } +break; +case 84: +#line 811 "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; + yyval.declarator->func_stack = yystack.l_mark[-3].declarator; + yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head; + yyval.declarator->func_def = FUNC_ANSI; + } +break; +case 85: +#line 819 "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; + yyval.declarator->func_stack = yystack.l_mark[-3].declarator; + yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head; + yyval.declarator->func_def = FUNC_TRADITIONAL; + } +break; +case 86: +#line 830 "grammar.y" + { + (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-1].text.begin; + } +break; +case 87: +#line 835 "grammar.y" + { + (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-2].text.begin; + } +break; +case 88: +#line 843 "grammar.y" + { + strcpy(yyval.text.text, ""); + yyval.text.begin = 0L; + } +break; +case 90: +#line 852 "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; + free(yystack.l_mark[0].decl_spec.text); + } +break; +case 91: +#line 858 "grammar.y" + { + (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, 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" + { + add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); + } +break; +case 94: +#line 875 "grammar.y" + { + new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); + } +break; +case 95: +#line 879 "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" + { + 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" + { + 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" + { + 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" + { + new_ident_list(&yyval.param_list); + } +break; +case 101: +#line 912 "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" + { + 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" + { + yyval.text = yystack.l_mark[0].text; + } +break; +case 104: +#line 928 "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); + yyval.text.begin = yystack.l_mark[-1].text.begin; + } +break; +case 105: +#line 941 "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" + { + yyval.declarator = yystack.l_mark[0].declarator; + (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, 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" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "(%s)", 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" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + } +break; +case 110: +#line 972 "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" + { + yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin); + yyval.declarator->params = yystack.l_mark[-1].param_list; + yyval.declarator->func_stack = yystack.l_mark[-3].declarator; + yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head; + yyval.declarator->func_def = FUNC_ANSI; + } +break; +case 112: +#line 984 "grammar.y" + { + yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin); + yyval.declarator->func_stack = yystack.l_mark[-2].declarator; + yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head; + yyval.declarator->func_def = FUNC_ANSI; + } +break; +case 113: +#line 991 "grammar.y" + { + Declarator *d; + + d = new_declarator("", "", yystack.l_mark[-2].text.begin); + yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin); + yyval.declarator->params = yystack.l_mark[-1].param_list; + yyval.declarator->func_stack = d; + yyval.declarator->head = yyval.declarator; + yyval.declarator->func_def = FUNC_ANSI; + } +break; +case 114: +#line 1002 "grammar.y" + { + Declarator *d; + + d = new_declarator("", "", yystack.l_mark[-1].text.begin); + yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin); + yyval.declarator->func_stack = d; + yyval.declarator->head = yyval.declarator; + yyval.declarator->func_def = FUNC_ANSI; + } +break; +#line 2579 "grammar.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/grammar.tab.h b/contrib/byacc/test/btyacc/grammar.tab.h new file mode 100644 index 000000000..f82e0d3f4 --- /dev/null +++ b/contrib/byacc/test/btyacc/grammar.tab.h @@ -0,0 +1,40 @@ +#ifndef _grammar__defines_h_ +#define _grammar__defines_h_ + +#define T_IDENTIFIER 257 +#define T_TYPEDEF_NAME 258 +#define T_DEFINE_NAME 259 +#define T_AUTO 260 +#define T_EXTERN 261 +#define T_REGISTER 262 +#define T_STATIC 263 +#define T_TYPEDEF 264 +#define T_INLINE 265 +#define T_EXTENSION 266 +#define T_CHAR 267 +#define T_DOUBLE 268 +#define T_FLOAT 269 +#define T_INT 270 +#define T_VOID 271 +#define T_LONG 272 +#define T_SHORT 273 +#define T_SIGNED 274 +#define T_UNSIGNED 275 +#define T_ENUM 276 +#define T_STRUCT 277 +#define T_UNION 278 +#define T_Bool 279 +#define T_Complex 280 +#define T_Imaginary 281 +#define T_TYPE_QUALIFIER 282 +#define T_BRACKETS 283 +#define T_LBRACE 284 +#define T_MATCHRBRACE 285 +#define T_ELLIPSIS 286 +#define T_INITIALIZER 287 +#define T_STRING_LITERAL 288 +#define T_ASM 289 +#define T_ASMARG 290 +#define T_VA_DCL 291 + +#endif /* _grammar__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/help.error b/contrib/byacc/test/btyacc/help.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/help.output b/contrib/byacc/test/btyacc/help.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/btyacc/help.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/btyacc/inherit0.error b/contrib/byacc/test/btyacc/inherit0.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/inherit0.output b/contrib/byacc/test/btyacc/inherit0.output new file mode 100644 index 000000000..ee5ca2e50 --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit0.output @@ -0,0 +1,165 @@ + 0 $accept : declaration $end + + 1 declaration : class type namelist + 2 | type locnamelist + + 3 class : GLOBAL + 4 | LOCAL + + 5 type : REAL + 6 | INTEGER + + 7 namelist : namelist NAME + 8 | NAME + + 9 $$1 : + + 10 $$2 : + + 11 locnamelist : $$1 $$2 namelist + +state 0 + $accept : . declaration $end (0) + + GLOBAL shift 1 + LOCAL shift 2 + REAL shift 3 + INTEGER shift 4 + . error + + declaration goto 5 + class goto 6 + type goto 7 + + +state 1 + class : GLOBAL . (3) + + . reduce 3 + + +state 2 + class : LOCAL . (4) + + . reduce 4 + + +state 3 + type : REAL . (5) + + . reduce 5 + + +state 4 + type : INTEGER . (6) + + . reduce 6 + + +state 5 + $accept : declaration . $end (0) + + $end accept + + +state 6 + declaration : class . type namelist (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . locnamelist (2) + $$1 : . (9) + + . reduce 9 + + locnamelist goto 9 + $$1 goto 10 + + +state 8 + declaration : class type . namelist (1) + + NAME shift 11 + . error + + namelist goto 12 + + +state 9 + declaration : type locnamelist . (2) + + . reduce 2 + + +state 10 + locnamelist : $$1 . $$2 namelist (11) + $$2 : . (10) + + . reduce 10 + + $$2 goto 13 + + +state 11 + namelist : NAME . (8) + + . reduce 8 + + +state 12 + declaration : class type namelist . (1) + namelist : namelist . NAME (7) + + NAME shift 14 + $end reduce 1 + + +state 13 + locnamelist : $$1 $$2 . namelist (11) + + NAME shift 11 + . error + + namelist goto 15 + + +state 14 + namelist : namelist NAME . (7) + + . reduce 7 + + +state 15 + namelist : namelist . NAME (7) + locnamelist : $$1 $$2 namelist . (11) + + NAME shift 14 + $end reduce 11 + + +7 terminals, 8 nonterminals +12 grammar rules, 16 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 GLOBAL + 3 258 LOCAL + 4 259 REAL + 5 260 INTEGER + 6 261 NAME + 7 262 $accept + 8 263 declaration + 9 264 class + 10 265 type + 11 266 namelist + 12 267 locnamelist + 13 268 $$1 + 14 269 $$2 diff --git a/contrib/byacc/test/btyacc/inherit0.tab.c b/contrib/byacc/test/btyacc/inherit0.tab.c new file mode 100644 index 000000000..238d5ab60 --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit0.tab.c @@ -0,0 +1,1321 @@ +/* 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 inherit0_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex inherit0_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror inherit0_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar inherit0_char +#endif /* yychar */ + +#ifndef yyval +#define yyval inherit0_val +#endif /* yyval */ + +#ifndef yylval +#define yylval inherit0_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug inherit0_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs inherit0_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag inherit0_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs inherit0_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen inherit0_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred inherit0_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos inherit0_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto inherit0_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex inherit0_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex inherit0_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex inherit0_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable inherit0_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck inherit0_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname inherit0_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule inherit0_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex inherit0_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable inherit0_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "inherit0_" + +#define YYPURE 0 + +#line 2 "inherit0.y" +extern void mksymbol(int t, int c, int id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#endif +#line 130 "inherit0.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 GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT inherit0_lhs[] = { -1, + 0, 0, 1, 1, 2, 2, 3, 3, 5, 6, + 4, +}; +static const YYINT inherit0_len[] = { 2, + 3, 2, 1, 1, 1, 1, 2, 1, 0, 0, + 3, +}; +static const YYINT inherit0_defred[] = { 0, + 3, 4, 5, 6, 0, 0, 9, 0, 2, 10, + 8, 0, 0, 7, 0, +}; +static const YYINT inherit0_stos[] = { 0, + 257, 258, 259, 260, 263, 264, 265, 265, 267, 268, + 261, 266, 269, 261, 266, +}; +static const YYINT inherit0_dgoto[] = { 5, + 6, 7, 12, 9, 10, 13, +}; +static const YYINT inherit0_sindex[] = { -257, + 0, 0, 0, 0, 0, -255, 0, -254, 0, 0, + 0, -253, -254, 0, -253, +}; +static const YYINT inherit0_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6, 0, 0, 9, +}; +#if YYBTYACC +static const YYINT inherit0_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +}; +#endif +static const YYINT inherit0_gindex[] = { 0, + 0, 4, -2, 0, 0, 0, +}; +#define YYTABLESIZE 11 +static const YYINT inherit0_table[] = { 1, + 2, 3, 4, 3, 4, 1, 11, 14, 11, 8, + 15, +}; +static const YYINT inherit0_check[] = { 257, + 258, 259, 260, 259, 260, 0, 261, 261, 0, 6, + 13, +}; +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 270 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const inherit0_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","GLOBAL","LOCAL","REAL","INTEGER", +"NAME","$accept","declaration","class","type","namelist","locnamelist","$$1", +"$$2","illegal-symbol", +}; +static const char *const inherit0_rule[] = { +"$accept : declaration", +"declaration : class type namelist", +"declaration : type locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"$$1 :", +"$$2 :", +"locnamelist : $$1 $$2 namelist", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 46 "inherit0.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 386 "inherit0.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 20 "inherit0.y" + { yyval = yystack.l_mark[0]; } +break; +case 2: +#line 22 "inherit0.y" + { yyval = yystack.l_mark[0]; } +break; +case 3: +#line 25 "inherit0.y" + { yyval = 1; } +break; +case 4: +#line 26 "inherit0.y" + { yyval = 2; } +break; +case 5: +#line 29 "inherit0.y" + { yyval = 1; } +break; +case 6: +#line 30 "inherit0.y" + { yyval = 2; } +break; +case 7: +#line 34 "inherit0.y" + { mksymbol(yystack.l_mark[-2], yystack.l_mark[-3], yystack.l_mark[0]); } +break; +case 8: +#line 36 "inherit0.y" + { mksymbol(yystack.l_mark[-1], yystack.l_mark[-2], yystack.l_mark[0]); } +break; +case 9: +#line 40 "inherit0.y" + { yyval = 2; } +break; +case 10: +#line 41 "inherit0.y" + { yyval = yystack.l_mark[-2]; } +break; +case 11: +#line 43 "inherit0.y" + { yyval = yystack.l_mark[0]; } +break; +#line 1087 "inherit0.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/inherit0.tab.h b/contrib/byacc/test/btyacc/inherit0.tab.h new file mode 100644 index 000000000..50ecd392f --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit0.tab.h @@ -0,0 +1,10 @@ +#ifndef _inherit0__defines_h_ +#define _inherit0__defines_h_ + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 + +#endif /* _inherit0__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/inherit1.error b/contrib/byacc/test/btyacc/inherit1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/inherit1.output b/contrib/byacc/test/btyacc/inherit1.output new file mode 100644 index 000000000..349f1657d --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit1.output @@ -0,0 +1,165 @@ + 0 $accept : declaration $end + + 1 declaration : class type namelist + 2 | type locnamelist + + 3 class : GLOBAL + 4 | LOCAL + + 5 type : REAL + 6 | INTEGER + + 7 namelist : namelist NAME + 8 | NAME + + 9 $$1 : + + 10 $$2 : + + 11 locnamelist : $$1 $$2 namelist + +state 0 + $accept : . declaration $end (0) + + GLOBAL shift 1 + LOCAL shift 2 + REAL shift 3 + INTEGER shift 4 + . error + + declaration goto 5 + class goto 6 + type goto 7 + + +state 1 + class : GLOBAL . (3) + + . reduce 3 + + +state 2 + class : LOCAL . (4) + + . reduce 4 + + +state 3 + type : REAL . (5) + + . reduce 5 + + +state 4 + type : INTEGER . (6) + + . reduce 6 + + +state 5 + $accept : declaration . $end (0) + + $end accept + + +state 6 + declaration : class . type namelist (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . locnamelist (2) + $$1 : . (9) + + . reduce 9 + + locnamelist goto 9 + $$1 goto 10 + + +state 8 + declaration : class type . namelist (1) + + NAME shift 11 + . error + + namelist goto 12 + + +state 9 + declaration : type locnamelist . (2) + + . reduce 2 + + +state 10 + locnamelist : $$1 . $$2 namelist (11) + $$2 : . (10) + + . reduce 10 + + $$2 goto 13 + + +state 11 + namelist : NAME . (8) + + . reduce 8 + + +state 12 + declaration : class type namelist . (1) + namelist : namelist . NAME (7) + + NAME shift 14 + $end reduce 1 + + +state 13 + locnamelist : $$1 $$2 . namelist (11) + + NAME shift 11 + . error + + namelist goto 15 + + +state 14 + namelist : namelist NAME . (7) + + . reduce 7 + + +state 15 + namelist : namelist . NAME (7) + locnamelist : $$1 $$2 namelist . (11) + + NAME shift 14 + $end reduce 11 + + +7 terminals, 8 nonterminals +12 grammar rules, 16 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 GLOBAL + 3 258 LOCAL + 4 259 REAL + 5 260 INTEGER + 6 261 NAME + 7 262 $accept + 8 263 declaration + 9 264 namelist + 10 265 locnamelist + 11 266 class + 12 267 type + 13 268 $$1 + 14 269 $$2 diff --git a/contrib/byacc/test/btyacc/inherit1.tab.c b/contrib/byacc/test/btyacc/inherit1.tab.c new file mode 100644 index 000000000..126812e22 --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit1.tab.c @@ -0,0 +1,1346 @@ +/* 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 inherit1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex inherit1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror inherit1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar inherit1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval inherit1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval inherit1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug inherit1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs inherit1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag inherit1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs inherit1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen inherit1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred inherit1_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos inherit1_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto inherit1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex inherit1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex inherit1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex inherit1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable inherit1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck inherit1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname inherit1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule inherit1_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex inherit1_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable inherit1_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "inherit1_" + +#define YYPURE 0 + +#line 2 "inherit1.y" +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#endif +#line 32 "inherit1.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 157 "inherit1.tab.c" + +/* 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 GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT inherit1_lhs[] = { -1, + 0, 0, 3, 3, 4, 4, 1, 1, 5, 6, + 2, +}; +static const YYINT inherit1_len[] = { 2, + 3, 2, 1, 1, 1, 1, 2, 1, 0, 0, + 3, +}; +static const YYINT inherit1_defred[] = { 0, + 3, 4, 5, 6, 0, 0, 9, 0, 2, 10, + 8, 0, 0, 7, 0, +}; +static const YYINT inherit1_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 265, 268, + 261, 264, 269, 261, 264, +}; +static const YYINT inherit1_dgoto[] = { 5, + 12, 9, 6, 7, 10, 13, +}; +static const YYINT inherit1_sindex[] = { -257, + 0, 0, 0, 0, 0, -255, 0, -254, 0, 0, + 0, -253, -254, 0, -253, +}; +static const YYINT inherit1_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6, 0, 0, 9, +}; +#if YYBTYACC +static const YYINT inherit1_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +}; +#endif +static const YYINT inherit1_gindex[] = { 0, + -3, 0, 0, 5, 0, 0, +}; +#define YYTABLESIZE 11 +static const YYINT inherit1_table[] = { 1, + 2, 3, 4, 3, 4, 1, 11, 14, 11, 15, + 8, +}; +static const YYINT inherit1_check[] = { 257, + 258, 259, 260, 259, 260, 0, 261, 261, 0, 13, + 6, +}; +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 270 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const inherit1_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","GLOBAL","LOCAL","REAL","INTEGER", +"NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", +"$$2","illegal-symbol", +}; +static const char *const inherit1_rule[] = { +"$accept : declaration", +"declaration : class type namelist", +"declaration : type locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"$$1 :", +"$$2 :", +"locnamelist : $$1 $$2 namelist", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 74 "inherit1.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 407 "inherit1.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 44 "inherit1.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 2: +#line 46 "inherit1.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 3: +#line 49 "inherit1.y" + { yyval.cval = cGLOBAL; } +break; +case 4: +#line 50 "inherit1.y" + { yyval.cval = cLOCAL; } +break; +case 5: +#line 53 "inherit1.y" + { yyval.tval = tREAL; } +break; +case 6: +#line 54 "inherit1.y" + { yyval.tval = tINTEGER; } +break; +case 7: +#line 58 "inherit1.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id); + yyval.nlist->next = yystack.l_mark[-1].nlist; + } +break; +case 8: +#line 62 "inherit1.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); + yyval.nlist->next = NULL; + } +break; +case 9: +#line 68 "inherit1.y" + { yyval.cval = cLOCAL; } +break; +case 10: +#line 69 "inherit1.y" + { yyval.tval = yystack.l_mark[-2].tval; } +break; +case 11: +#line 71 "inherit1.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +#line 1112 "inherit1.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/inherit1.tab.h b/contrib/byacc/test/btyacc/inherit1.tab.h new file mode 100644 index 000000000..3b8aa3d2a --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit1.tab.h @@ -0,0 +1,25 @@ +#ifndef _inherit1__defines_h_ +#define _inherit1__defines_h_ + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE inherit1_lval; + +#endif /* _inherit1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/inherit2.error b/contrib/byacc/test/btyacc/inherit2.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/inherit2.output b/contrib/byacc/test/btyacc/inherit2.output new file mode 100644 index 000000000..70ffb0592 --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit2.output @@ -0,0 +1,199 @@ + 0 $accept : declaration $end + + 1 $$1 : + + 2 $$2 : + + 3 declaration : class type $$1 $$2 namelist + + 4 $$3 : + + 5 declaration : type $$3 locnamelist + + 6 class : GLOBAL + 7 | LOCAL + + 8 type : REAL + 9 | INTEGER + + 10 namelist : namelist NAME + 11 | NAME + + 12 $$4 : + + 13 locnamelist : $$4 $$2 namelist + +state 0 + $accept : . declaration $end (0) + + GLOBAL shift 1 + LOCAL shift 2 + REAL shift 3 + INTEGER shift 4 + . error + + declaration goto 5 + class goto 6 + type goto 7 + + +state 1 + class : GLOBAL . (6) + + . reduce 6 + + +state 2 + class : LOCAL . (7) + + . reduce 7 + + +state 3 + type : REAL . (8) + + . reduce 8 + + +state 4 + type : INTEGER . (9) + + . reduce 9 + + +state 5 + $accept : declaration . $end (0) + + $end accept + + +state 6 + declaration : class . type $$1 $$2 namelist (3) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . $$3 locnamelist (5) + $$3 : . (4) + + . reduce 4 + + $$3 goto 9 + + +state 8 + declaration : class type . $$1 $$2 namelist (3) + $$1 : . (1) + + . reduce 1 + + $$1 goto 10 + + +state 9 + declaration : type $$3 . locnamelist (5) + $$4 : . (12) + + . reduce 12 + + locnamelist goto 11 + $$4 goto 12 + + +state 10 + declaration : class type $$1 . $$2 namelist (3) + $$2 : . (2) + + . reduce 2 + + $$2 goto 13 + + +state 11 + declaration : type $$3 locnamelist . (5) + + . reduce 5 + + +state 12 + locnamelist : $$4 . $$2 namelist (13) + $$2 : . (2) + + . reduce 2 + + $$2 goto 14 + + +state 13 + declaration : class type $$1 $$2 . namelist (3) + + NAME shift 15 + . error + + namelist goto 16 + + +state 14 + locnamelist : $$4 $$2 . namelist (13) + + NAME shift 15 + . error + + namelist goto 17 + + +state 15 + namelist : NAME . (11) + + . reduce 11 + + +state 16 + declaration : class type $$1 $$2 namelist . (3) + namelist : namelist . NAME (10) + + NAME shift 18 + $end reduce 3 + + +state 17 + namelist : namelist . NAME (10) + locnamelist : $$4 $$2 namelist . (13) + + NAME shift 18 + $end reduce 13 + + +state 18 + namelist : namelist NAME . (10) + + . reduce 10 + + +7 terminals, 10 nonterminals +14 grammar rules, 19 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 GLOBAL + 3 258 LOCAL + 4 259 REAL + 5 260 INTEGER + 6 261 NAME + 7 262 $accept + 8 263 declaration + 9 264 namelist + 10 265 locnamelist + 11 266 class + 12 267 type + 13 268 $$1 + 14 269 $$2 + 15 270 $$3 + 16 271 $$4 diff --git a/contrib/byacc/test/btyacc/inherit2.tab.c b/contrib/byacc/test/btyacc/inherit2.tab.c new file mode 100644 index 000000000..d32cbe760 --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit2.tab.c @@ -0,0 +1,1409 @@ +/* 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 inherit2_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex inherit2_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror inherit2_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar inherit2_char +#endif /* yychar */ + +#ifndef yyval +#define yyval inherit2_val +#endif /* yyval */ + +#ifndef yylval +#define yylval inherit2_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug inherit2_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs inherit2_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag inherit2_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs inherit2_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen inherit2_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred inherit2_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos inherit2_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto inherit2_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex inherit2_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex inherit2_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex inherit2_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable inherit2_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck inherit2_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname inherit2_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule inherit2_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex inherit2_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable inherit2_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "inherit2_" + +#define YYPURE 0 + +#line 2 "inherit2.y" +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +#line 39 "inherit2.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 155 "inherit2.tab.c" + +/* 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 + +#ifndef YYDESTRUCT_DECL +#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val) +#endif +#ifndef YYDESTRUCT_CALL +#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val) +#endif + +extern int YYPARSE_DECL(); + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT inherit2_lhs[] = { -1, + 5, 6, 0, 7, 0, 3, 3, 4, 4, 1, + 1, 8, 2, +}; +static const YYINT inherit2_len[] = { 2, + 0, 0, 5, 0, 3, 1, 1, 1, 1, 2, + 1, 0, 3, +}; +static const YYINT inherit2_defred[] = { 0, + 6, 7, 8, 9, 0, 0, 4, 1, 12, 2, + 5, 2, 0, 0, 11, 0, 0, 10, +}; +static const YYINT inherit2_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 270, 268, + 265, 271, 269, 269, 261, 264, 264, 261, +}; +static const YYINT inherit2_dgoto[] = { 5, + 16, 11, 6, 7, 10, 13, 9, 12, +}; +static const YYINT inherit2_sindex[] = { -257, + 0, 0, 0, 0, 0, -255, 0, 0, 0, 0, + 0, 0, -254, -254, 0, -253, -253, 0, +}; +static const YYINT inherit2_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 6, 9, 0, +}; +#if YYBTYACC +static const YYINT inherit2_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; +#endif +static const YYINT inherit2_gindex[] = { 0, + -4, 0, 0, 5, 0, 1, 0, 0, +}; +#define YYTABLESIZE 13 +static const YYINT inherit2_table[] = { 1, + 2, 3, 4, 3, 4, 3, 15, 18, 13, 17, + 8, 0, 14, +}; +static const YYINT inherit2_check[] = { 257, + 258, 259, 260, 259, 260, 0, 261, 261, 0, 14, + 6, -1, 12, +}; +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 272 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const inherit2_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","GLOBAL","LOCAL","REAL","INTEGER", +"NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", +"$$2","$$3","$$4","illegal-symbol", +}; +static const char *const inherit2_rule[] = { +"$accept : declaration", +"$$1 :", +"$$2 :", +"declaration : class type $$1 $$2 namelist", +"$$3 :", +"declaration : type $$3 locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"$$4 :", +"locnamelist : $$4 $$2 namelist", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 78 "inherit2.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 414 "inherit2.tab.c" + +/* Release memory associated with symbol. */ +#if ! defined YYDESTRUCT_IS_DECLARED +static void +YYDESTRUCT_DECL() +{ + switch (psymb) + { + case 263: +#line 30 "inherit2.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + break; +#line 434 "inherit2.tab.c" + case 264: +#line 30 "inherit2.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + break; +#line 446 "inherit2.tab.c" + case 265: +#line 30 "inherit2.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + break; +#line 458 "inherit2.tab.c" + } +} +#define YYDESTRUCT_IS_DECLARED 1 +#endif + +/* 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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 1: +#line 50 "inherit2.y" +yyval.cval = yystack.l_mark[-1].cval; +break; +case 2: +#line 50 "inherit2.y" +yyval.tval = yystack.l_mark[-1].tval; +break; +case 3: +#line 51 "inherit2.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 4: +#line 52 "inherit2.y" +yyval.tval = yystack.l_mark[0].tval; +break; +case 5: +#line 53 "inherit2.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +case 6: +#line 56 "inherit2.y" + { yyval.cval = cGLOBAL; } +break; +case 7: +#line 57 "inherit2.y" + { yyval.cval = cLOCAL; } +break; +case 8: +#line 60 "inherit2.y" + { yyval.tval = tREAL; } +break; +case 9: +#line 61 "inherit2.y" + { yyval.tval = tINTEGER; } +break; +case 10: +#line 65 "inherit2.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id); + yyval.nlist->next = yystack.l_mark[-1].nlist; + } +break; +case 11: +#line 69 "inherit2.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); + yyval.nlist->next = NULL; + } +break; +case 12: +#line 74 "inherit2.y" +yyval.cval = cLOCAL; +break; +case 13: +#line 75 "inherit2.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +break; +#line 1175 "inherit2.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/inherit2.tab.h b/contrib/byacc/test/btyacc/inherit2.tab.h new file mode 100644 index 000000000..efaf4555d --- /dev/null +++ b/contrib/byacc/test/btyacc/inherit2.tab.h @@ -0,0 +1,25 @@ +#ifndef _inherit2__defines_h_ +#define _inherit2__defines_h_ + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE inherit2_lval; + +#endif /* _inherit2__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/no_b_opt.error b/contrib/byacc/test/btyacc/no_b_opt.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_b_opt.output b/contrib/byacc/test/btyacc/no_b_opt.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_b_opt.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/btyacc/no_b_opt1.error b/contrib/byacc/test/btyacc/no_b_opt1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_b_opt1.output b/contrib/byacc/test/btyacc/no_b_opt1.output new file mode 100644 index 000000000..87286c266 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_b_opt1.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_code_c.error b/contrib/byacc/test/btyacc/no_code_c.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_code_c.output b/contrib/byacc/test/btyacc/no_code_c.output new file mode 100644 index 000000000..87286c266 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_code_c.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_defines.error b/contrib/byacc/test/btyacc/no_defines.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_defines.output b/contrib/byacc/test/btyacc/no_defines.output new file mode 100644 index 000000000..773985d66 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_defines.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.h" diff --git a/contrib/byacc/test/btyacc/no_graph.error b/contrib/byacc/test/btyacc/no_graph.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_graph.output b/contrib/byacc/test/btyacc/no_graph.output new file mode 100644 index 000000000..d5575f400 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_graph.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.dot" diff --git a/contrib/byacc/test/btyacc/no_include.error b/contrib/byacc/test/btyacc/no_include.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_include.output b/contrib/byacc/test/btyacc/no_include.output new file mode 100644 index 000000000..3ece4a454 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_include.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.i" diff --git a/contrib/byacc/test/btyacc/no_opts.error b/contrib/byacc/test/btyacc/no_opts.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_opts.output b/contrib/byacc/test/btyacc/no_opts.output new file mode 100644 index 000000000..ad3131a69 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_opts.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.y" diff --git a/contrib/byacc/test/btyacc/no_output.error b/contrib/byacc/test/btyacc/no_output.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_output.output b/contrib/byacc/test/btyacc/no_output.output new file mode 100644 index 000000000..a2f142a9d --- /dev/null +++ b/contrib/byacc/test/btyacc/no_output.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/no_output1.error b/contrib/byacc/test/btyacc/no_output1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_output1.output b/contrib/byacc/test/btyacc/no_output1.output new file mode 100644 index 000000000..a2f142a9d --- /dev/null +++ b/contrib/byacc/test/btyacc/no_output1.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/no_output2.error b/contrib/byacc/test/btyacc/no_output2.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_output2.output b/contrib/byacc/test/btyacc/no_output2.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_output2.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/btyacc/no_p_opt.error b/contrib/byacc/test/btyacc/no_p_opt.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_p_opt.output b/contrib/byacc/test/btyacc/no_p_opt.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_p_opt.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/btyacc/no_p_opt1.error b/contrib/byacc/test/btyacc/no_p_opt1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_p_opt1.output b/contrib/byacc/test/btyacc/no_p_opt1.output new file mode 100644 index 000000000..87286c266 --- /dev/null +++ b/contrib/byacc/test/btyacc/no_p_opt1.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_verbose.error b/contrib/byacc/test/btyacc/no_verbose.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/no_verbose.output b/contrib/byacc/test/btyacc/no_verbose.output new file mode 100644 index 000000000..a2f142a9d --- /dev/null +++ b/contrib/byacc/test/btyacc/no_verbose.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/nostdin.error b/contrib/byacc/test/btyacc/nostdin.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/nostdin.output b/contrib/byacc/test/btyacc/nostdin.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/btyacc/nostdin.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/btyacc/ok_syntax1.error b/contrib/byacc/test/btyacc/ok_syntax1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/ok_syntax1.output b/contrib/byacc/test/btyacc/ok_syntax1.output new file mode 100644 index 000000000..61935519b --- /dev/null +++ b/contrib/byacc/test/btyacc/ok_syntax1.output @@ -0,0 +1,511 @@ + 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 + '\n' reduce 15 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' 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 + '\n' reduce 16 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' 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 + '\n' reduce 13 + '|' 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 + '\n' reduce 12 + '|' reduce 12 + '&' 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 + '\n' reduce 7 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' 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 + '\n' reduce 8 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' 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 + + +42 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 259 OCT1 + 5 127 '\177' + 6 260 HEX1 + 7 255 '\377' + 8 261 HEX2 + 9 262 HEX3 + 10 263 STR1 + 11 264 "\177\177\\\n" + 12 265 STR2 + 13 266 BELL + 14 7 '\a' + 15 267 BS + 16 8 '\b' + 17 268 NL + 18 10 '\n' + 19 269 LF + 20 12 '\f' + 21 270 CR + 22 13 '\r' + 23 271 TAB + 24 9 '\t' + 25 272 VT + 26 11 '\v' + 27 64 '@' + 28 126 '~' + 29 94 '^' + 30 35 '#' + 31 124 '|' + 32 38 '&' + 33 43 '+' + 34 45 '-' + 35 42 '*' + 36 47 '/' + 37 37 '%' + 38 273 UMINUS + 39 61 '=' + 40 40 '(' + 41 41 ')' + 42 274 $accept + 43 275 list + 44 276 stat + 45 277 expr + 46 278 number diff --git a/contrib/byacc/test/btyacc/ok_syntax1.tab.c b/contrib/byacc/test/btyacc/ok_syntax1.tab.c new file mode 100644 index 000000000..37e08284b --- /dev/null +++ b/contrib/byacc/test/btyacc/ok_syntax1.tab.c @@ -0,0 +1,1472 @@ +/* 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 ok_syntax1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex ok_syntax1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror ok_syntax1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar ok_syntax1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval ok_syntax1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval ok_syntax1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug ok_syntax1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs ok_syntax1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag ok_syntax1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs ok_syntax1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen ok_syntax1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred ok_syntax1_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos ok_syntax1_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto ok_syntax1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex ok_syntax1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex ok_syntax1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex ok_syntax1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable ok_syntax1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck ok_syntax1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname ok_syntax1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule ok_syntax1_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex ok_syntax1_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable ok_syntax1_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "ok_syntax1_" + +#define YYPURE 1 + +#line 9 "ok_syntax1.y" +# include +# include + +#ifdef YYBISON +#define YYSTYPE int +#define YYLEX_PARAM base +#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM) +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +#line 43 "ok_syntax1.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + char * cval; + int ival; + double dval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 148 "ok_syntax1.tab.c" + +/* 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(int regs[26], int * base) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# ifdef YYLEX_PARAM_TYPE +# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) +# else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) +# endif +# define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base) +# define YYLEX yylex(&yylval, base) +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(regs, base, msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define OCT1 259 +#define HEX1 260 +#define HEX2 261 +#define HEX3 262 +#define STR1 263 +#define STR2 265 +#define BELL 266 +#define BS 267 +#define NL 268 +#define LF 269 +#define CR 270 +#define TAB 271 +#define VT 272 +#define UMINUS 273 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT ok_syntax1_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT ok_syntax1_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT ok_syntax1_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 ok_syntax1_stos[] = { 0, + 275, 256, 257, 258, 45, 40, 276, 277, 278, 10, + 61, 258, 277, 277, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 277, 41, 277, 277, 277, 277, 277, + 277, 277, +}; +static const YYINT ok_syntax1_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT ok_syntax1_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 ok_syntax1_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 ok_syntax1_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 ok_syntax1_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT ok_syntax1_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 ok_syntax1_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 273 +#define YYUNDFTOKEN 279 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const ok_syntax1_name[] = { + +"$end",0,0,0,0,0,0,"'\\a'","'\\b'","'\\t'","'\\n'","'\\v'","'\\f'","'\\r'",0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'#'",0,"'%'","'&'",0,"'('","')'","'*'", +"'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,"'@'",0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,"'~'","'\\177'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'\\377'", +"error","DIGIT","LETTER","OCT1","HEX1","HEX2","HEX3","STR1", +"\"\\177\\177\\\\\\n\"","STR2","BELL","BS","NL","LF","CR","TAB","VT","UMINUS", +"$accept","list","stat","expr","number","illegal-symbol", +}; +static const char *const ok_syntax1_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 + +int yydebug; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 */ +#line 104 "ok_syntax1.y" + /* start of programs */ + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main (void) +{ + int regs[26]; + int base = 10; + + while(!feof(stdin)) { + yyparse(regs, &base); + } + return 0; +} + +#define UNUSED(x) ((void)(x)) + +static void +YYERROR_DECL() +{ + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ + fprintf(stderr, "%s\n", s); +} + +int +YYLEX_DECL() +{ + /* 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->ival = (c - 'a'); + return ( LETTER ); + } + if( isdigit( c )) { + yylval->ival = (c - '0') % (*base); + return ( DIGIT ); + } + return( c ); +} +#line 471 "ok_syntax1.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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 yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* variables for the parser stack */ + 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 short *yylexp = 0; + + static short *yylexemes = 0; +#endif /* YYBTYACC */ + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 66 "ok_syntax1.y" + { yyerrok ; } +break; +case 4: +#line 70 "ok_syntax1.y" + { printf("%d\n",yystack.l_mark[0].ival);} +break; +case 5: +#line 72 "ok_syntax1.y" + { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } +break; +case 6: +#line 76 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-1].ival; } +break; +case 7: +#line 78 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } +break; +case 8: +#line 80 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } +break; +case 9: +#line 82 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } +break; +case 10: +#line 84 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } +break; +case 11: +#line 86 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } +break; +case 12: +#line 88 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } +break; +case 13: +#line 90 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } +break; +case 14: +#line 92 "ok_syntax1.y" + { yyval.ival = - yystack.l_mark[0].ival; } +break; +case 15: +#line 94 "ok_syntax1.y" + { yyval.ival = regs[yystack.l_mark[0].ival]; } +break; +case 17: +#line 99 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } +break; +case 18: +#line 101 "ok_syntax1.y" + { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } +break; +#line 1238 "ok_syntax1.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/ok_syntax1.tab.h b/contrib/byacc/test/btyacc/ok_syntax1.tab.h new file mode 100644 index 000000000..75e9a96c9 --- /dev/null +++ b/contrib/byacc/test/btyacc/ok_syntax1.tab.h @@ -0,0 +1,35 @@ +#ifndef _ok_syntax1__defines_h_ +#define _ok_syntax1__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define OCT1 259 +#define HEX1 260 +#define HEX2 261 +#define HEX3 262 +#define STR1 263 +#define STR2 265 +#define BELL 266 +#define BS 267 +#define NL 268 +#define LF 269 +#define CR 270 +#define TAB 271 +#define VT 272 +#define UMINUS 273 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + char * cval; + int ival; + double dval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE ok_syntax1_lval; + +#endif /* _ok_syntax1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/pure_calc.error b/contrib/byacc/test/btyacc/pure_calc.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/pure_calc.output b/contrib/byacc/test/btyacc/pure_calc.output new file mode 100644 index 000000000..c689eec05 --- /dev/null +++ b/contrib/byacc/test/btyacc/pure_calc.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/contrib/byacc/test/btyacc/pure_calc.tab.c b/contrib/byacc/test/btyacc/pure_calc.tab.c new file mode 100644 index 000000000..28de5d6ac --- /dev/null +++ b/contrib/byacc/test/btyacc/pure_calc.tab.c @@ -0,0 +1,1445 @@ +/* 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_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 yystos +#define yystos calc_stos +#endif /* yystos */ + +#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 */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_" + +#define YYPURE 1 + +#line 2 "pure_calc.y" +# include +# include + +int regs[26]; +int base; + +#ifdef YYBISON +#define YYSTYPE int +#define YYLEX_PARAM &yylval +#define YYLEX_DECL() yylex(YYSTYPE *yylval) +#define YYERROR_DECL() yyerror(const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +#line 137 "pure_calc.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 +# ifdef YYLEX_PARAM_TYPE +# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) +# else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) +# endif +# define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(YYSTYPE *yylval) +# define YYLEX yylex(&yylval) +#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_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT 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 YYINT calc_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, +}; +static const YYINT calc_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT 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 YYINT 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, +}; +#if YYBTYACC +static const YYINT calc_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_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT 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 YYINT 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 YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_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_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 + +int yydebug; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 */ +#line 72 "pure_calc.y" + /* start of programs */ + +#ifdef YYBYACC +static int YYLEX_DECL(); +#endif + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +YYERROR_DECL() +{ + fprintf(stderr, "%s\n", s); +} + +int +YYLEX_DECL() +{ + /* 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 444 "pure_calc.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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 yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* variables for the parser stack */ + 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 short *yylexp = 0; + + static short *yylexemes = 0; +#endif /* YYBTYACC */ + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 34 "pure_calc.y" + { yyerrok ; } +break; +case 4: +#line 38 "pure_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 40 "pure_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 44 "pure_calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 46 "pure_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 48 "pure_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 50 "pure_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 52 "pure_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 54 "pure_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 56 "pure_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 58 "pure_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 60 "pure_calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 62 "pure_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 67 "pure_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 69 "pure_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1211 "pure_calc.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/pure_calc.tab.h b/contrib/byacc/test/btyacc/pure_calc.tab.h new file mode 100644 index 000000000..48f8993b8 --- /dev/null +++ b/contrib/byacc/test/btyacc/pure_calc.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc__defines_h_ +#define _calc__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/pure_error.error b/contrib/byacc/test/btyacc/pure_error.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/pure_error.output b/contrib/byacc/test/btyacc/pure_error.output new file mode 100644 index 000000000..1e56c214a --- /dev/null +++ b/contrib/byacc/test/btyacc/pure_error.output @@ -0,0 +1,34 @@ + 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/contrib/byacc/test/btyacc/pure_error.tab.c b/contrib/byacc/test/btyacc/pure_error.tab.c new file mode 100644 index 000000000..2f3b697aa --- /dev/null +++ b/contrib/byacc/test/btyacc/pure_error.tab.c @@ -0,0 +1,1274 @@ +/* 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 error_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex error_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror error_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar error_char +#endif /* yychar */ + +#ifndef yyval +#define yyval error_val +#endif /* yyval */ + +#ifndef yylval +#define yylval error_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug error_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs error_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag error_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs error_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen error_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred error_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos error_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto error_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex error_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex error_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex error_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable error_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck error_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname error_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule error_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex error_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable error_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "error_" + +#define YYPURE 1 + +#line 2 "pure_error.y" + +#ifdef YYBISON +#define YYSTYPE int +#define YYLEX_PARAM &yylval +#define YYLEX_DECL() yylex(YYSTYPE *yylval) +#define YYERROR_DECL() yyerror(const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +#line 132 "pure_error.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 +# ifdef YYLEX_PARAM_TYPE +# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) +# else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) +# endif +# define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(YYSTYPE *yylval) +# define YYLEX yylex(&yylval) +#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 YYERRCODE 256 +typedef short YYINT; +static const YYINT error_lhs[] = { -1, + 0, +}; +static const YYINT error_len[] = { 2, + 1, +}; +static const YYINT error_defred[] = { 0, + 1, 0, +}; +static const YYINT error_stos[] = { 0, + 256, 258, +}; +static const YYINT error_dgoto[] = { 2, +}; +static const YYINT error_sindex[] = { -256, + 0, 0, +}; +static const YYINT error_rindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT error_cindex[] = { 0, + 0, 0, +}; +#endif +static const YYINT error_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT error_table[] = { 1, +}; +static const YYINT error_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const error_name[] = { + +"$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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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", +}; +static const char *const error_rule[] = { +"$accept : S", +"S : error", + +}; +#endif + +int yydebug; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 */ +#line 17 "pure_error.y" + +#include + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(YYSTYPE *value) +{ + return value ? 0 : -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 334 "pure_error.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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 yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* variables for the parser stack */ + 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 short *yylexp = 0; + + static short *yylexemes = 0; +#endif /* YYBTYACC */ + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/pure_error.tab.h b/contrib/byacc/test/btyacc/pure_error.tab.h new file mode 100644 index 000000000..f9e5ad278 --- /dev/null +++ b/contrib/byacc/test/btyacc/pure_error.tab.h @@ -0,0 +1,5 @@ +#ifndef _error__defines_h_ +#define _error__defines_h_ + + +#endif /* _error__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc-s.error b/contrib/byacc/test/btyacc/quote_calc-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc-s.output b/contrib/byacc/test/btyacc/quote_calc-s.output new file mode 100644 index 000000000..6c25d0911 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc-s.output @@ -0,0 +1,593 @@ + 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 OP_ADD expr + 8 | expr OP_SUB expr + 9 | expr OP_MUL expr + 10 | expr OP_DIV expr + 11 | expr OP_MOD expr + 12 | expr OP_AND expr + 13 | expr '|' expr + 14 | OP_SUB 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 + OP_SUB shift 3 + DIGIT shift 4 + LETTER 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 + expr : OP_SUB . expr (14) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + OP_ADD reduce 15 + OP_SUB reduce 15 + OP_MUL reduce 15 + OP_DIV reduce 15 + OP_MOD reduce 15 + OP_AND reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + OP_ADD reduce 16 + OP_SUB reduce 16 + OP_MUL reduce 16 + OP_DIV reduce 16 + OP_MOD reduce 16 + OP_AND reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD +12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB +12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL +12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV +12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD +12: shift/reduce conflict (shift 21, reduce 14) on OP_AND +state 12 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : OP_SUB expr . (14) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr OP_ADD . expr (7) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr OP_SUB . expr (8) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr OP_MUL . expr (9) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr OP_DIV . expr (10) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr OP_MOD . expr (11) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr OP_AND . expr (12) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD +26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB +26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL +26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV +26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD +26: shift/reduce conflict (shift 21, reduce 7) on OP_AND +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . OP_ADD expr (7) + expr : expr OP_ADD expr . (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD +27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB +27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL +27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV +27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD +27: shift/reduce conflict (shift 21, reduce 8) on OP_AND +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr OP_SUB expr . (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD +28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB +28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL +28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV +28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD +28: shift/reduce conflict (shift 21, reduce 9) on OP_AND +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr OP_MUL expr . (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD +29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB +29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL +29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV +29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD +29: shift/reduce conflict (shift 21, reduce 10) on OP_AND +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr OP_DIV expr . (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD +30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB +30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL +30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV +30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD +30: shift/reduce conflict (shift 21, reduce 11) on OP_AND +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr OP_MOD expr . (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD +31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB +31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL +31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV +31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD +31: shift/reduce conflict (shift 21, reduce 12) on OP_AND +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr OP_AND expr . (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD +32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB +32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL +32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV +32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD +32: shift/reduce conflict (shift 21, reduce 13) on OP_AND +state 32 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD" + 4 259 OP_SUB + 5 260 "SUB" + 6 261 OP_MUL + 7 262 "MUL" + 8 263 OP_DIV + 9 264 "DIV" + 10 265 OP_MOD + 11 266 "MOD" + 12 267 OP_AND + 13 268 "AND" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc-s.tab.c b/contrib/byacc/test/btyacc/quote_calc-s.tab.c new file mode 100644 index 000000000..93d94adbd --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc-s.tab.c @@ -0,0 +1,1445 @@ +/* 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 quote_calc_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc_" + +#define YYPURE 0 + +#line 2 "quote_calc.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc-s.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 OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc_stos[] = { 0, + 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, + 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc_sindex[] = { 0, + -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, + 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc_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 quote_calc_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 258 +static const YYINT quote_calc_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, + 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 17, 0, 18, + 0, 19, 0, 20, 0, 21, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, + 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 257, -1, 259, -1, 261, + -1, 263, -1, 265, -1, 267, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + 259, -1, 259, -1, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 257, -1, 259, -1, 261, -1, + 263, -1, 265, -1, 267, -1, 257, 257, 259, 259, + 261, 261, 263, 263, 265, 265, 267, 267, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc_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","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"$accept","list","stat","expr","number","illegal-symbol", +}; +static const char *const quote_calc_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr OP_ADD expr", +"expr : expr OP_SUB expr", +"expr : expr OP_MUL expr", +"expr : expr OP_DIV expr", +"expr : expr OP_MOD expr", +"expr : expr OP_AND expr", +"expr : expr '|' expr", +"expr : OP_SUB expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_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 494 "quote_calc-s.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1211 "quote_calc-s.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc-s.tab.h b/contrib/byacc/test/btyacc/quote_calc-s.tab.h new file mode 100644 index 000000000..827bd8d11 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc-s.tab.h @@ -0,0 +1,14 @@ +#ifndef _quote_calc__defines_h_ +#define _quote_calc__defines_h_ + +#define OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc.error b/contrib/byacc/test/btyacc/quote_calc.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc.output b/contrib/byacc/test/btyacc/quote_calc.output new file mode 100644 index 000000000..6c25d0911 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc.output @@ -0,0 +1,593 @@ + 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 OP_ADD expr + 8 | expr OP_SUB expr + 9 | expr OP_MUL expr + 10 | expr OP_DIV expr + 11 | expr OP_MOD expr + 12 | expr OP_AND expr + 13 | expr '|' expr + 14 | OP_SUB 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 + OP_SUB shift 3 + DIGIT shift 4 + LETTER 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 + expr : OP_SUB . expr (14) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + OP_ADD reduce 15 + OP_SUB reduce 15 + OP_MUL reduce 15 + OP_DIV reduce 15 + OP_MOD reduce 15 + OP_AND reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + OP_ADD reduce 16 + OP_SUB reduce 16 + OP_MUL reduce 16 + OP_DIV reduce 16 + OP_MOD reduce 16 + OP_AND reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD +12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB +12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL +12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV +12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD +12: shift/reduce conflict (shift 21, reduce 14) on OP_AND +state 12 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : OP_SUB expr . (14) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr OP_ADD . expr (7) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr OP_SUB . expr (8) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr OP_MUL . expr (9) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr OP_DIV . expr (10) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr OP_MOD . expr (11) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr OP_AND . expr (12) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD +26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB +26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL +26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV +26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD +26: shift/reduce conflict (shift 21, reduce 7) on OP_AND +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . OP_ADD expr (7) + expr : expr OP_ADD expr . (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD +27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB +27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL +27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV +27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD +27: shift/reduce conflict (shift 21, reduce 8) on OP_AND +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr OP_SUB expr . (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD +28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB +28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL +28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV +28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD +28: shift/reduce conflict (shift 21, reduce 9) on OP_AND +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr OP_MUL expr . (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD +29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB +29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL +29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV +29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD +29: shift/reduce conflict (shift 21, reduce 10) on OP_AND +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr OP_DIV expr . (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD +30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB +30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL +30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV +30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD +30: shift/reduce conflict (shift 21, reduce 11) on OP_AND +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr OP_MOD expr . (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD +31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB +31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL +31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV +31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD +31: shift/reduce conflict (shift 21, reduce 12) on OP_AND +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr OP_AND expr . (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD +32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB +32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL +32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV +32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD +32: shift/reduce conflict (shift 21, reduce 13) on OP_AND +state 32 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD" + 4 259 OP_SUB + 5 260 "SUB" + 6 261 OP_MUL + 7 262 "MUL" + 8 263 OP_DIV + 9 264 "DIV" + 10 265 OP_MOD + 11 266 "MOD" + 12 267 OP_AND + 13 268 "AND" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc.tab.c b/contrib/byacc/test/btyacc/quote_calc.tab.c new file mode 100644 index 000000000..56c7abcf5 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc.tab.c @@ -0,0 +1,1451 @@ +/* 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 quote_calc_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc_" + +#define YYPURE 0 + +#line 2 "quote_calc.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc.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 OP_ADD 257 +#define ADD 258 +#define OP_SUB 259 +#define SUB 260 +#define OP_MUL 261 +#define MUL 262 +#define OP_DIV 263 +#define DIV 264 +#define OP_MOD 265 +#define MOD 266 +#define OP_AND 267 +#define AND 268 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc_stos[] = { 0, + 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, + 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc_sindex[] = { 0, + -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, + 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc_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 quote_calc_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 258 +static const YYINT quote_calc_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, + 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 17, 0, 18, + 0, 19, 0, 20, 0, 21, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, + 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 257, -1, 259, -1, 261, + -1, 263, -1, 265, -1, 267, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + 259, -1, 259, -1, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 257, -1, 259, -1, 261, -1, + 263, -1, 265, -1, 267, -1, 257, 257, 259, 259, + 261, 261, 263, 263, 265, 265, 267, 267, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc_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","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"$accept","list","stat","expr","number","illegal-symbol", +}; +static const char *const quote_calc_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr OP_ADD expr", +"expr : expr OP_SUB expr", +"expr : expr OP_MUL expr", +"expr : expr OP_DIV expr", +"expr : expr OP_MOD expr", +"expr : expr OP_AND expr", +"expr : expr '|' expr", +"expr : OP_SUB expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_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 500 "quote_calc.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1217 "quote_calc.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc.tab.h b/contrib/byacc/test/btyacc/quote_calc.tab.h new file mode 100644 index 000000000..2067aeea9 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc.tab.h @@ -0,0 +1,20 @@ +#ifndef _quote_calc__defines_h_ +#define _quote_calc__defines_h_ + +#define OP_ADD 257 +#define ADD 258 +#define OP_SUB 259 +#define SUB 260 +#define OP_MUL 261 +#define MUL 262 +#define OP_DIV 263 +#define DIV 264 +#define OP_MOD 265 +#define MOD 266 +#define OP_AND 267 +#define AND 268 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc2-s.error b/contrib/byacc/test/btyacc/quote_calc2-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc2-s.output b/contrib/byacc/test/btyacc/quote_calc2-s.output new file mode 100644 index 000000000..ce0b8f1ba --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2-s.output @@ -0,0 +1,593 @@ + 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 "ADD" expr + 8 | expr "SUB" expr + 9 | expr "MUL" expr + 10 | expr "DIV" expr + 11 | expr "MOD" expr + 12 | expr "AND" expr + 13 | expr '|' expr + 14 | "SUB" 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 + "SUB" shift 3 + DIGIT shift 4 + LETTER 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 + expr : "SUB" . expr (14) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + "ADD" reduce 15 + "SUB" reduce 15 + "MUL" reduce 15 + "DIV" reduce 15 + "MOD" reduce 15 + "AND" reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + "ADD" reduce 16 + "SUB" reduce 16 + "MUL" reduce 16 + "DIV" reduce 16 + "MOD" reduce 16 + "AND" reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on "ADD" +12: shift/reduce conflict (shift 17, reduce 14) on "SUB" +12: shift/reduce conflict (shift 18, reduce 14) on "MUL" +12: shift/reduce conflict (shift 19, reduce 14) on "DIV" +12: shift/reduce conflict (shift 20, reduce 14) on "MOD" +12: shift/reduce conflict (shift 21, reduce 14) on "AND" +state 12 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + expr : "SUB" expr . (14) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr "ADD" . expr (7) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr "SUB" . expr (8) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr "MUL" . expr (9) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr "DIV" . expr (10) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr "MOD" . expr (11) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr "AND" . expr (12) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on "ADD" +26: shift/reduce conflict (shift 17, reduce 7) on "SUB" +26: shift/reduce conflict (shift 18, reduce 7) on "MUL" +26: shift/reduce conflict (shift 19, reduce 7) on "DIV" +26: shift/reduce conflict (shift 20, reduce 7) on "MOD" +26: shift/reduce conflict (shift 21, reduce 7) on "AND" +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . "ADD" expr (7) + expr : expr "ADD" expr . (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on "ADD" +27: shift/reduce conflict (shift 17, reduce 8) on "SUB" +27: shift/reduce conflict (shift 18, reduce 8) on "MUL" +27: shift/reduce conflict (shift 19, reduce 8) on "DIV" +27: shift/reduce conflict (shift 20, reduce 8) on "MOD" +27: shift/reduce conflict (shift 21, reduce 8) on "AND" +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr "SUB" expr . (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on "ADD" +28: shift/reduce conflict (shift 17, reduce 9) on "SUB" +28: shift/reduce conflict (shift 18, reduce 9) on "MUL" +28: shift/reduce conflict (shift 19, reduce 9) on "DIV" +28: shift/reduce conflict (shift 20, reduce 9) on "MOD" +28: shift/reduce conflict (shift 21, reduce 9) on "AND" +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr "MUL" expr . (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on "ADD" +29: shift/reduce conflict (shift 17, reduce 10) on "SUB" +29: shift/reduce conflict (shift 18, reduce 10) on "MUL" +29: shift/reduce conflict (shift 19, reduce 10) on "DIV" +29: shift/reduce conflict (shift 20, reduce 10) on "MOD" +29: shift/reduce conflict (shift 21, reduce 10) on "AND" +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr "DIV" expr . (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on "ADD" +30: shift/reduce conflict (shift 17, reduce 11) on "SUB" +30: shift/reduce conflict (shift 18, reduce 11) on "MUL" +30: shift/reduce conflict (shift 19, reduce 11) on "DIV" +30: shift/reduce conflict (shift 20, reduce 11) on "MOD" +30: shift/reduce conflict (shift 21, reduce 11) on "AND" +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr "MOD" expr . (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on "ADD" +31: shift/reduce conflict (shift 17, reduce 12) on "SUB" +31: shift/reduce conflict (shift 18, reduce 12) on "MUL" +31: shift/reduce conflict (shift 19, reduce 12) on "DIV" +31: shift/reduce conflict (shift 20, reduce 12) on "MOD" +31: shift/reduce conflict (shift 21, reduce 12) on "AND" +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr "AND" expr . (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on "ADD" +32: shift/reduce conflict (shift 17, reduce 13) on "SUB" +32: shift/reduce conflict (shift 18, reduce 13) on "MUL" +32: shift/reduce conflict (shift 19, reduce 13) on "DIV" +32: shift/reduce conflict (shift 20, reduce 13) on "MOD" +32: shift/reduce conflict (shift 21, reduce 13) on "AND" +state 32 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD" + 4 259 OP_SUB + 5 260 "SUB" + 6 261 OP_MUL + 7 262 "MUL" + 8 263 OP_DIV + 9 264 "DIV" + 10 265 OP_MOD + 11 266 "MOD" + 12 267 OP_AND + 13 268 "AND" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc2-s.tab.c b/contrib/byacc/test/btyacc/quote_calc2-s.tab.c new file mode 100644 index 000000000..be41425e8 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2-s.tab.c @@ -0,0 +1,1445 @@ +/* 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 quote_calc2_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc2_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc2_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc2_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc2_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc2_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc2_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc2_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc2_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc2_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc2_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc2_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc2_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc2_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc2_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc2_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc2_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc2_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc2_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc2_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc2_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc2_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc2_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc2_" + +#define YYPURE 0 + +#line 2 "quote_calc2.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc2-s.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 OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc2_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc2_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc2_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc2_stos[] = { 0, + 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, + 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc2_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc2_sindex[] = { 0, + -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, + 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc2_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc2_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 quote_calc2_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 259 +static const YYINT quote_calc2_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, + 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 0, 17, 0, + 18, 0, 19, 0, 20, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc2_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, + 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 258, -1, 260, -1, + 262, -1, 264, -1, 266, -1, 268, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + -1, 260, -1, 260, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 258, -1, 260, -1, 262, -1, + 264, -1, 266, -1, 268, -1, -1, 258, 258, 260, + 260, 262, 262, 264, 264, 266, 266, 268, 268, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc2_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","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"$accept","list","stat","expr","number","illegal-symbol", +}; +static const char *const quote_calc2_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr \"ADD\" expr", +"expr : expr \"SUB\" expr", +"expr : expr \"MUL\" expr", +"expr : expr \"DIV\" expr", +"expr : expr \"MOD\" expr", +"expr : expr \"AND\" expr", +"expr : expr '|' expr", +"expr : \"SUB\" expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_calc2.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 494 "quote_calc2-s.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc2.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc2.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc2.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc2.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc2.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1211 "quote_calc2-s.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc2-s.tab.h b/contrib/byacc/test/btyacc/quote_calc2-s.tab.h new file mode 100644 index 000000000..90c0c1a2d --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2-s.tab.h @@ -0,0 +1,14 @@ +#ifndef _quote_calc2__defines_h_ +#define _quote_calc2__defines_h_ + +#define OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc2__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc2.error b/contrib/byacc/test/btyacc/quote_calc2.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc2.output b/contrib/byacc/test/btyacc/quote_calc2.output new file mode 100644 index 000000000..ce0b8f1ba --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2.output @@ -0,0 +1,593 @@ + 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 "ADD" expr + 8 | expr "SUB" expr + 9 | expr "MUL" expr + 10 | expr "DIV" expr + 11 | expr "MOD" expr + 12 | expr "AND" expr + 13 | expr '|' expr + 14 | "SUB" 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 + "SUB" shift 3 + DIGIT shift 4 + LETTER 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 + expr : "SUB" . expr (14) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + "ADD" reduce 15 + "SUB" reduce 15 + "MUL" reduce 15 + "DIV" reduce 15 + "MOD" reduce 15 + "AND" reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + "ADD" reduce 16 + "SUB" reduce 16 + "MUL" reduce 16 + "DIV" reduce 16 + "MOD" reduce 16 + "AND" reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on "ADD" +12: shift/reduce conflict (shift 17, reduce 14) on "SUB" +12: shift/reduce conflict (shift 18, reduce 14) on "MUL" +12: shift/reduce conflict (shift 19, reduce 14) on "DIV" +12: shift/reduce conflict (shift 20, reduce 14) on "MOD" +12: shift/reduce conflict (shift 21, reduce 14) on "AND" +state 12 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + expr : "SUB" expr . (14) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr "ADD" . expr (7) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr "SUB" . expr (8) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr "MUL" . expr (9) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr "DIV" . expr (10) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr "MOD" . expr (11) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr "AND" . expr (12) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + "SUB" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on "ADD" +26: shift/reduce conflict (shift 17, reduce 7) on "SUB" +26: shift/reduce conflict (shift 18, reduce 7) on "MUL" +26: shift/reduce conflict (shift 19, reduce 7) on "DIV" +26: shift/reduce conflict (shift 20, reduce 7) on "MOD" +26: shift/reduce conflict (shift 21, reduce 7) on "AND" +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . "ADD" expr (7) + expr : expr "ADD" expr . (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on "ADD" +27: shift/reduce conflict (shift 17, reduce 8) on "SUB" +27: shift/reduce conflict (shift 18, reduce 8) on "MUL" +27: shift/reduce conflict (shift 19, reduce 8) on "DIV" +27: shift/reduce conflict (shift 20, reduce 8) on "MOD" +27: shift/reduce conflict (shift 21, reduce 8) on "AND" +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr "SUB" expr . (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on "ADD" +28: shift/reduce conflict (shift 17, reduce 9) on "SUB" +28: shift/reduce conflict (shift 18, reduce 9) on "MUL" +28: shift/reduce conflict (shift 19, reduce 9) on "DIV" +28: shift/reduce conflict (shift 20, reduce 9) on "MOD" +28: shift/reduce conflict (shift 21, reduce 9) on "AND" +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr "MUL" expr . (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on "ADD" +29: shift/reduce conflict (shift 17, reduce 10) on "SUB" +29: shift/reduce conflict (shift 18, reduce 10) on "MUL" +29: shift/reduce conflict (shift 19, reduce 10) on "DIV" +29: shift/reduce conflict (shift 20, reduce 10) on "MOD" +29: shift/reduce conflict (shift 21, reduce 10) on "AND" +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr "DIV" expr . (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on "ADD" +30: shift/reduce conflict (shift 17, reduce 11) on "SUB" +30: shift/reduce conflict (shift 18, reduce 11) on "MUL" +30: shift/reduce conflict (shift 19, reduce 11) on "DIV" +30: shift/reduce conflict (shift 20, reduce 11) on "MOD" +30: shift/reduce conflict (shift 21, reduce 11) on "AND" +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr "MOD" expr . (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on "ADD" +31: shift/reduce conflict (shift 17, reduce 12) on "SUB" +31: shift/reduce conflict (shift 18, reduce 12) on "MUL" +31: shift/reduce conflict (shift 19, reduce 12) on "DIV" +31: shift/reduce conflict (shift 20, reduce 12) on "MOD" +31: shift/reduce conflict (shift 21, reduce 12) on "AND" +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr "AND" expr . (12) + expr : expr . '|' expr (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on "ADD" +32: shift/reduce conflict (shift 17, reduce 13) on "SUB" +32: shift/reduce conflict (shift 18, reduce 13) on "MUL" +32: shift/reduce conflict (shift 19, reduce 13) on "DIV" +32: shift/reduce conflict (shift 20, reduce 13) on "MOD" +32: shift/reduce conflict (shift 21, reduce 13) on "AND" +state 32 + expr : expr . "ADD" expr (7) + expr : expr . "SUB" expr (8) + expr : expr . "MUL" expr (9) + expr : expr . "DIV" expr (10) + expr : expr . "MOD" expr (11) + expr : expr . "AND" expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + "ADD" shift 16 + "SUB" shift 17 + "MUL" shift 18 + "DIV" shift 19 + "MOD" shift 20 + "AND" shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD" + 4 259 OP_SUB + 5 260 "SUB" + 6 261 OP_MUL + 7 262 "MUL" + 8 263 OP_DIV + 9 264 "DIV" + 10 265 OP_MOD + 11 266 "MOD" + 12 267 OP_AND + 13 268 "AND" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc2.tab.c b/contrib/byacc/test/btyacc/quote_calc2.tab.c new file mode 100644 index 000000000..496926ec3 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2.tab.c @@ -0,0 +1,1451 @@ +/* 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 quote_calc2_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc2_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc2_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc2_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc2_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc2_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc2_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc2_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc2_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc2_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc2_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc2_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc2_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc2_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc2_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc2_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc2_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc2_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc2_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc2_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc2_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc2_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc2_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc2_" + +#define YYPURE 0 + +#line 2 "quote_calc2.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc2.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 OP_ADD 257 +#define ADD 258 +#define OP_SUB 259 +#define SUB 260 +#define OP_MUL 261 +#define MUL 262 +#define OP_DIV 263 +#define DIV 264 +#define OP_MOD 265 +#define MOD 266 +#define OP_AND 267 +#define AND 268 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc2_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc2_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc2_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc2_stos[] = { 0, + 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, + 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc2_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc2_sindex[] = { 0, + -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, + 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc2_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc2_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 quote_calc2_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 259 +static const YYINT quote_calc2_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, + 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 0, 17, 0, + 18, 0, 19, 0, 20, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc2_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, + 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 258, -1, 260, -1, + 262, -1, 264, -1, 266, -1, 268, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + -1, 260, -1, 260, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 258, -1, 260, -1, 262, -1, + 264, -1, 266, -1, 268, -1, -1, 258, 258, 260, + 260, 262, 262, 264, 264, 266, 266, 268, 268, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc2_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","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"$accept","list","stat","expr","number","illegal-symbol", +}; +static const char *const quote_calc2_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr \"ADD\" expr", +"expr : expr \"SUB\" expr", +"expr : expr \"MUL\" expr", +"expr : expr \"DIV\" expr", +"expr : expr \"MOD\" expr", +"expr : expr \"AND\" expr", +"expr : expr '|' expr", +"expr : \"SUB\" expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_calc2.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 500 "quote_calc2.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc2.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc2.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc2.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc2.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc2.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1217 "quote_calc2.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc2.tab.h b/contrib/byacc/test/btyacc/quote_calc2.tab.h new file mode 100644 index 000000000..0c9db245c --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc2.tab.h @@ -0,0 +1,20 @@ +#ifndef _quote_calc2__defines_h_ +#define _quote_calc2__defines_h_ + +#define OP_ADD 257 +#define ADD 258 +#define OP_SUB 259 +#define SUB 260 +#define OP_MUL 261 +#define MUL 262 +#define OP_DIV 263 +#define DIV 264 +#define OP_MOD 265 +#define MOD 266 +#define OP_AND 267 +#define AND 268 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc2__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc3-s.error b/contrib/byacc/test/btyacc/quote_calc3-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc3-s.output b/contrib/byacc/test/btyacc/quote_calc3-s.output new file mode 100644 index 000000000..4809ca4c8 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3-s.output @@ -0,0 +1,593 @@ + 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 OP_ADD expr + 8 | expr OP_SUB expr + 9 | expr OP_MUL expr + 10 | expr OP_DIV expr + 11 | expr OP_MOD expr + 12 | expr OP_AND expr + 13 | expr '|' expr + 14 | OP_SUB 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 + OP_SUB shift 3 + DIGIT shift 4 + LETTER 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 + expr : OP_SUB . expr (14) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + OP_ADD reduce 15 + OP_SUB reduce 15 + OP_MUL reduce 15 + OP_DIV reduce 15 + OP_MOD reduce 15 + OP_AND reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + OP_ADD reduce 16 + OP_SUB reduce 16 + OP_MUL reduce 16 + OP_DIV reduce 16 + OP_MOD reduce 16 + OP_AND reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD +12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB +12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL +12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV +12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD +12: shift/reduce conflict (shift 21, reduce 14) on OP_AND +state 12 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : OP_SUB expr . (14) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr OP_ADD . expr (7) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr OP_SUB . expr (8) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr OP_MUL . expr (9) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr OP_DIV . expr (10) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr OP_MOD . expr (11) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr OP_AND . expr (12) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD +26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB +26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL +26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV +26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD +26: shift/reduce conflict (shift 21, reduce 7) on OP_AND +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . OP_ADD expr (7) + expr : expr OP_ADD expr . (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD +27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB +27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL +27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV +27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD +27: shift/reduce conflict (shift 21, reduce 8) on OP_AND +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr OP_SUB expr . (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD +28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB +28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL +28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV +28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD +28: shift/reduce conflict (shift 21, reduce 9) on OP_AND +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr OP_MUL expr . (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD +29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB +29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL +29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV +29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD +29: shift/reduce conflict (shift 21, reduce 10) on OP_AND +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr OP_DIV expr . (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD +30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB +30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL +30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV +30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD +30: shift/reduce conflict (shift 21, reduce 11) on OP_AND +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr OP_MOD expr . (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD +31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB +31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL +31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV +31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD +31: shift/reduce conflict (shift 21, reduce 12) on OP_AND +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr OP_AND expr . (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD +32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB +32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL +32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV +32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD +32: shift/reduce conflict (shift 21, reduce 13) on OP_AND +state 32 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD-operator" + 4 259 OP_SUB + 5 260 "SUB-operator" + 6 261 OP_MUL + 7 262 "MUL-operator" + 8 263 OP_DIV + 9 264 "DIV-operator" + 10 265 OP_MOD + 11 266 "MOD-operator" + 12 267 OP_AND + 13 268 "AND-operator" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc3-s.tab.c b/contrib/byacc/test/btyacc/quote_calc3-s.tab.c new file mode 100644 index 000000000..a7072f9da --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3-s.tab.c @@ -0,0 +1,1446 @@ +/* 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 quote_calc3_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc3_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc3_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc3_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc3_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc3_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc3_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc3_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc3_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc3_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc3_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc3_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc3_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc3_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc3_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc3_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc3_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc3_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc3_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc3_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc3_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc3_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc3_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc3_" + +#define YYPURE 0 + +#line 2 "quote_calc3.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc3-s.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 OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc3_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc3_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc3_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc3_stos[] = { 0, + 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, + 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc3_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc3_sindex[] = { 0, + -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, + 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc3_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc3_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 quote_calc3_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 258 +static const YYINT quote_calc3_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, + 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 17, 0, 18, + 0, 19, 0, 20, 0, 21, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc3_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, + 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 257, -1, 259, -1, 261, + -1, 263, -1, 265, -1, 267, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + 259, -1, 259, -1, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 257, -1, 259, -1, 261, -1, + 263, -1, 265, -1, 267, -1, 257, 257, 259, 259, + 261, 261, 263, 263, 265, 265, 267, 267, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc3_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","OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", +"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS","$accept","list","stat", +"expr","number","illegal-symbol", +}; +static const char *const quote_calc3_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr OP_ADD expr", +"expr : expr OP_SUB expr", +"expr : expr OP_MUL expr", +"expr : expr OP_DIV expr", +"expr : expr OP_MOD expr", +"expr : expr OP_AND expr", +"expr : expr '|' expr", +"expr : OP_SUB expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_calc3.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 495 "quote_calc3-s.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc3.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc3.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc3.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc3.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc3.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1212 "quote_calc3-s.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc3-s.tab.h b/contrib/byacc/test/btyacc/quote_calc3-s.tab.h new file mode 100644 index 000000000..022d59c67 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3-s.tab.h @@ -0,0 +1,14 @@ +#ifndef _quote_calc3__defines_h_ +#define _quote_calc3__defines_h_ + +#define OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc3__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc3.error b/contrib/byacc/test/btyacc/quote_calc3.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc3.output b/contrib/byacc/test/btyacc/quote_calc3.output new file mode 100644 index 000000000..4809ca4c8 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3.output @@ -0,0 +1,593 @@ + 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 OP_ADD expr + 8 | expr OP_SUB expr + 9 | expr OP_MUL expr + 10 | expr OP_DIV expr + 11 | expr OP_MOD expr + 12 | expr OP_AND expr + 13 | expr '|' expr + 14 | OP_SUB 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 + OP_SUB shift 3 + DIGIT shift 4 + LETTER 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 + expr : OP_SUB . expr (14) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + OP_ADD reduce 15 + OP_SUB reduce 15 + OP_MUL reduce 15 + OP_DIV reduce 15 + OP_MOD reduce 15 + OP_AND reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + OP_ADD reduce 16 + OP_SUB reduce 16 + OP_MUL reduce 16 + OP_DIV reduce 16 + OP_MOD reduce 16 + OP_AND reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD +12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB +12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL +12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV +12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD +12: shift/reduce conflict (shift 21, reduce 14) on OP_AND +state 12 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : OP_SUB expr . (14) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr OP_ADD . expr (7) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr OP_SUB . expr (8) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr OP_MUL . expr (9) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr OP_DIV . expr (10) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr OP_MOD . expr (11) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr OP_AND . expr (12) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + OP_SUB shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD +26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB +26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL +26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV +26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD +26: shift/reduce conflict (shift 21, reduce 7) on OP_AND +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . OP_ADD expr (7) + expr : expr OP_ADD expr . (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD +27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB +27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL +27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV +27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD +27: shift/reduce conflict (shift 21, reduce 8) on OP_AND +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr OP_SUB expr . (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD +28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB +28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL +28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV +28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD +28: shift/reduce conflict (shift 21, reduce 9) on OP_AND +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr OP_MUL expr . (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD +29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB +29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL +29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV +29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD +29: shift/reduce conflict (shift 21, reduce 10) on OP_AND +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr OP_DIV expr . (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD +30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB +30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL +30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV +30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD +30: shift/reduce conflict (shift 21, reduce 11) on OP_AND +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr OP_MOD expr . (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD +31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB +31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL +31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV +31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD +31: shift/reduce conflict (shift 21, reduce 12) on OP_AND +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr OP_AND expr . (12) + expr : expr . '|' expr (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD +32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB +32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL +32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV +32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD +32: shift/reduce conflict (shift 21, reduce 13) on OP_AND +state 32 + expr : expr . OP_ADD expr (7) + expr : expr . OP_SUB expr (8) + expr : expr . OP_MUL expr (9) + expr : expr . OP_DIV expr (10) + expr : expr . OP_MOD expr (11) + expr : expr . OP_AND expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + OP_ADD shift 16 + OP_SUB shift 17 + OP_MUL shift 18 + OP_DIV shift 19 + OP_MOD shift 20 + OP_AND shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD-operator" + 4 259 OP_SUB + 5 260 "SUB-operator" + 6 261 OP_MUL + 7 262 "MUL-operator" + 8 263 OP_DIV + 9 264 "DIV-operator" + 10 265 OP_MOD + 11 266 "MOD-operator" + 12 267 OP_AND + 13 268 "AND-operator" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc3.tab.c b/contrib/byacc/test/btyacc/quote_calc3.tab.c new file mode 100644 index 000000000..6b1331403 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3.tab.c @@ -0,0 +1,1446 @@ +/* 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 quote_calc3_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc3_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc3_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc3_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc3_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc3_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc3_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc3_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc3_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc3_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc3_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc3_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc3_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc3_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc3_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc3_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc3_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc3_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc3_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc3_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc3_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc3_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc3_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc3_" + +#define YYPURE 0 + +#line 2 "quote_calc3.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc3.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 OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc3_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc3_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc3_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc3_stos[] = { 0, + 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, + 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc3_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc3_sindex[] = { 0, + -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, + 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc3_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc3_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 quote_calc3_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 258 +static const YYINT quote_calc3_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, + 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 17, 0, 18, + 0, 19, 0, 20, 0, 21, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc3_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, + 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 257, -1, 259, -1, 261, + -1, 263, -1, 265, -1, 267, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + 259, -1, 259, -1, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 257, -1, 259, -1, 261, -1, + 263, -1, 265, -1, 267, -1, 257, 257, 259, 259, + 261, 261, 263, 263, 265, 265, 267, 267, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc3_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","OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", +"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS","$accept","list","stat", +"expr","number","illegal-symbol", +}; +static const char *const quote_calc3_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr OP_ADD expr", +"expr : expr OP_SUB expr", +"expr : expr OP_MUL expr", +"expr : expr OP_DIV expr", +"expr : expr OP_MOD expr", +"expr : expr OP_AND expr", +"expr : expr '|' expr", +"expr : OP_SUB expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_calc3.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 495 "quote_calc3.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc3.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc3.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc3.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc3.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc3.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1212 "quote_calc3.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc3.tab.h b/contrib/byacc/test/btyacc/quote_calc3.tab.h new file mode 100644 index 000000000..022d59c67 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc3.tab.h @@ -0,0 +1,14 @@ +#ifndef _quote_calc3__defines_h_ +#define _quote_calc3__defines_h_ + +#define OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc3__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc4-s.error b/contrib/byacc/test/btyacc/quote_calc4-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc4-s.output b/contrib/byacc/test/btyacc/quote_calc4-s.output new file mode 100644 index 000000000..5f1f610d8 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4-s.output @@ -0,0 +1,593 @@ + 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 "ADD-operator" expr + 8 | expr "SUB-operator" expr + 9 | expr "MUL-operator" expr + 10 | expr "DIV-operator" expr + 11 | expr "MOD-operator" expr + 12 | expr "AND-operator" expr + 13 | expr '|' expr + 14 | "SUB-operator" 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 + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER 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 + expr : "SUB-operator" . expr (14) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + "ADD-operator" reduce 15 + "SUB-operator" reduce 15 + "MUL-operator" reduce 15 + "DIV-operator" reduce 15 + "MOD-operator" reduce 15 + "AND-operator" reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + "ADD-operator" reduce 16 + "SUB-operator" reduce 16 + "MUL-operator" reduce 16 + "DIV-operator" reduce 16 + "MOD-operator" reduce 16 + "AND-operator" reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on "ADD-operator" +12: shift/reduce conflict (shift 17, reduce 14) on "SUB-operator" +12: shift/reduce conflict (shift 18, reduce 14) on "MUL-operator" +12: shift/reduce conflict (shift 19, reduce 14) on "DIV-operator" +12: shift/reduce conflict (shift 20, reduce 14) on "MOD-operator" +12: shift/reduce conflict (shift 21, reduce 14) on "AND-operator" +state 12 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + expr : "SUB-operator" expr . (14) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr "ADD-operator" . expr (7) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr "SUB-operator" . expr (8) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr "MUL-operator" . expr (9) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr "DIV-operator" . expr (10) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr "MOD-operator" . expr (11) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr "AND-operator" . expr (12) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on "ADD-operator" +26: shift/reduce conflict (shift 17, reduce 7) on "SUB-operator" +26: shift/reduce conflict (shift 18, reduce 7) on "MUL-operator" +26: shift/reduce conflict (shift 19, reduce 7) on "DIV-operator" +26: shift/reduce conflict (shift 20, reduce 7) on "MOD-operator" +26: shift/reduce conflict (shift 21, reduce 7) on "AND-operator" +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . "ADD-operator" expr (7) + expr : expr "ADD-operator" expr . (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on "ADD-operator" +27: shift/reduce conflict (shift 17, reduce 8) on "SUB-operator" +27: shift/reduce conflict (shift 18, reduce 8) on "MUL-operator" +27: shift/reduce conflict (shift 19, reduce 8) on "DIV-operator" +27: shift/reduce conflict (shift 20, reduce 8) on "MOD-operator" +27: shift/reduce conflict (shift 21, reduce 8) on "AND-operator" +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr "SUB-operator" expr . (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on "ADD-operator" +28: shift/reduce conflict (shift 17, reduce 9) on "SUB-operator" +28: shift/reduce conflict (shift 18, reduce 9) on "MUL-operator" +28: shift/reduce conflict (shift 19, reduce 9) on "DIV-operator" +28: shift/reduce conflict (shift 20, reduce 9) on "MOD-operator" +28: shift/reduce conflict (shift 21, reduce 9) on "AND-operator" +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr "MUL-operator" expr . (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on "ADD-operator" +29: shift/reduce conflict (shift 17, reduce 10) on "SUB-operator" +29: shift/reduce conflict (shift 18, reduce 10) on "MUL-operator" +29: shift/reduce conflict (shift 19, reduce 10) on "DIV-operator" +29: shift/reduce conflict (shift 20, reduce 10) on "MOD-operator" +29: shift/reduce conflict (shift 21, reduce 10) on "AND-operator" +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr "DIV-operator" expr . (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on "ADD-operator" +30: shift/reduce conflict (shift 17, reduce 11) on "SUB-operator" +30: shift/reduce conflict (shift 18, reduce 11) on "MUL-operator" +30: shift/reduce conflict (shift 19, reduce 11) on "DIV-operator" +30: shift/reduce conflict (shift 20, reduce 11) on "MOD-operator" +30: shift/reduce conflict (shift 21, reduce 11) on "AND-operator" +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr "MOD-operator" expr . (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on "ADD-operator" +31: shift/reduce conflict (shift 17, reduce 12) on "SUB-operator" +31: shift/reduce conflict (shift 18, reduce 12) on "MUL-operator" +31: shift/reduce conflict (shift 19, reduce 12) on "DIV-operator" +31: shift/reduce conflict (shift 20, reduce 12) on "MOD-operator" +31: shift/reduce conflict (shift 21, reduce 12) on "AND-operator" +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr "AND-operator" expr . (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on "ADD-operator" +32: shift/reduce conflict (shift 17, reduce 13) on "SUB-operator" +32: shift/reduce conflict (shift 18, reduce 13) on "MUL-operator" +32: shift/reduce conflict (shift 19, reduce 13) on "DIV-operator" +32: shift/reduce conflict (shift 20, reduce 13) on "MOD-operator" +32: shift/reduce conflict (shift 21, reduce 13) on "AND-operator" +state 32 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD-operator" + 4 259 OP_SUB + 5 260 "SUB-operator" + 6 261 OP_MUL + 7 262 "MUL-operator" + 8 263 OP_DIV + 9 264 "DIV-operator" + 10 265 OP_MOD + 11 266 "MOD-operator" + 12 267 OP_AND + 13 268 "AND-operator" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc4-s.tab.c b/contrib/byacc/test/btyacc/quote_calc4-s.tab.c new file mode 100644 index 000000000..df8a95789 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4-s.tab.c @@ -0,0 +1,1446 @@ +/* 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 quote_calc4_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc4_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc4_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc4_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc4_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc4_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc4_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc4_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc4_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc4_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc4_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc4_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc4_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc4_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc4_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc4_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc4_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc4_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc4_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc4_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc4_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc4_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc4_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc4_" + +#define YYPURE 0 + +#line 2 "quote_calc4.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc4-s.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 OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc4_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc4_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc4_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc4_stos[] = { 0, + 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, + 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc4_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc4_sindex[] = { 0, + -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, + 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc4_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc4_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 quote_calc4_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 259 +static const YYINT quote_calc4_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, + 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 0, 17, 0, + 18, 0, 19, 0, 20, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc4_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, + 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 258, -1, 260, -1, + 262, -1, 264, -1, 266, -1, 268, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + -1, 260, -1, 260, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 258, -1, 260, -1, 262, -1, + 264, -1, 266, -1, 268, -1, -1, 258, 258, 260, + 260, 262, 262, 264, 264, 266, 266, 268, 268, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc4_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","OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", +"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS","$accept","list","stat", +"expr","number","illegal-symbol", +}; +static const char *const quote_calc4_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr \"ADD-operator\" expr", +"expr : expr \"SUB-operator\" expr", +"expr : expr \"MUL-operator\" expr", +"expr : expr \"DIV-operator\" expr", +"expr : expr \"MOD-operator\" expr", +"expr : expr \"AND-operator\" expr", +"expr : expr '|' expr", +"expr : \"SUB-operator\" expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_calc4.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 495 "quote_calc4-s.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc4.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc4.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc4.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc4.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc4.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc4.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc4.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc4.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc4.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc4.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc4.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc4.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc4.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc4.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc4.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1212 "quote_calc4-s.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc4-s.tab.h b/contrib/byacc/test/btyacc/quote_calc4-s.tab.h new file mode 100644 index 000000000..9279e7019 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4-s.tab.h @@ -0,0 +1,14 @@ +#ifndef _quote_calc4__defines_h_ +#define _quote_calc4__defines_h_ + +#define OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc4__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/quote_calc4.error b/contrib/byacc/test/btyacc/quote_calc4.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/quote_calc4.output b/contrib/byacc/test/btyacc/quote_calc4.output new file mode 100644 index 000000000..5f1f610d8 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4.output @@ -0,0 +1,593 @@ + 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 "ADD-operator" expr + 8 | expr "SUB-operator" expr + 9 | expr "MUL-operator" expr + 10 | expr "DIV-operator" expr + 11 | expr "MOD-operator" expr + 12 | expr "AND-operator" expr + 13 | expr '|' expr + 14 | "SUB-operator" 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 + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER 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 + expr : "SUB-operator" . expr (14) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 12 + number goto 9 + + +state 4 + number : DIGIT . (17) + + . reduce 17 + + +state 5 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 13 + "ADD-operator" reduce 15 + "SUB-operator" reduce 15 + "MUL-operator" reduce 15 + "DIV-operator" reduce 15 + "MOD-operator" reduce 15 + "AND-operator" reduce 15 + '|' reduce 15 + '\n' reduce 15 + + +state 6 + expr : '(' . expr ')' (6) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + "ADD-operator" reduce 16 + "SUB-operator" reduce 16 + "MUL-operator" reduce 16 + "DIV-operator" reduce 16 + "MOD-operator" reduce 16 + "AND-operator" reduce 16 + '|' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + expr : LETTER . (15) + + . reduce 15 + + +12: shift/reduce conflict (shift 16, reduce 14) on "ADD-operator" +12: shift/reduce conflict (shift 17, reduce 14) on "SUB-operator" +12: shift/reduce conflict (shift 18, reduce 14) on "MUL-operator" +12: shift/reduce conflict (shift 19, reduce 14) on "DIV-operator" +12: shift/reduce conflict (shift 20, reduce 14) on "MOD-operator" +12: shift/reduce conflict (shift 21, reduce 14) on "AND-operator" +state 12 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + expr : "SUB-operator" expr . (14) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' reduce 14 + '\n' reduce 14 + ')' reduce 14 + + +state 13 + stat : LETTER '=' . expr (5) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr "ADD-operator" . expr (7) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr "SUB-operator" . expr (8) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr "MUL-operator" . expr (9) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr "DIV-operator" . expr (10) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr "MOD-operator" . expr (11) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr "AND-operator" . expr (12) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '|' . expr (13) + + "SUB-operator" shift 3 + DIGIT shift 4 + LETTER shift 11 + '(' 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 . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +26: shift/reduce conflict (shift 16, reduce 7) on "ADD-operator" +26: shift/reduce conflict (shift 17, reduce 7) on "SUB-operator" +26: shift/reduce conflict (shift 18, reduce 7) on "MUL-operator" +26: shift/reduce conflict (shift 19, reduce 7) on "DIV-operator" +26: shift/reduce conflict (shift 20, reduce 7) on "MOD-operator" +26: shift/reduce conflict (shift 21, reduce 7) on "AND-operator" +26: shift/reduce conflict (shift 22, reduce 7) on '|' +state 26 + expr : expr . "ADD-operator" expr (7) + expr : expr "ADD-operator" expr . (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 7 + ')' reduce 7 + + +27: shift/reduce conflict (shift 16, reduce 8) on "ADD-operator" +27: shift/reduce conflict (shift 17, reduce 8) on "SUB-operator" +27: shift/reduce conflict (shift 18, reduce 8) on "MUL-operator" +27: shift/reduce conflict (shift 19, reduce 8) on "DIV-operator" +27: shift/reduce conflict (shift 20, reduce 8) on "MOD-operator" +27: shift/reduce conflict (shift 21, reduce 8) on "AND-operator" +27: shift/reduce conflict (shift 22, reduce 8) on '|' +state 27 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr "SUB-operator" expr . (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 8 + ')' reduce 8 + + +28: shift/reduce conflict (shift 16, reduce 9) on "ADD-operator" +28: shift/reduce conflict (shift 17, reduce 9) on "SUB-operator" +28: shift/reduce conflict (shift 18, reduce 9) on "MUL-operator" +28: shift/reduce conflict (shift 19, reduce 9) on "DIV-operator" +28: shift/reduce conflict (shift 20, reduce 9) on "MOD-operator" +28: shift/reduce conflict (shift 21, reduce 9) on "AND-operator" +28: shift/reduce conflict (shift 22, reduce 9) on '|' +state 28 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr "MUL-operator" expr . (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 9 + ')' reduce 9 + + +29: shift/reduce conflict (shift 16, reduce 10) on "ADD-operator" +29: shift/reduce conflict (shift 17, reduce 10) on "SUB-operator" +29: shift/reduce conflict (shift 18, reduce 10) on "MUL-operator" +29: shift/reduce conflict (shift 19, reduce 10) on "DIV-operator" +29: shift/reduce conflict (shift 20, reduce 10) on "MOD-operator" +29: shift/reduce conflict (shift 21, reduce 10) on "AND-operator" +29: shift/reduce conflict (shift 22, reduce 10) on '|' +state 29 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr "DIV-operator" expr . (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 10 + ')' reduce 10 + + +30: shift/reduce conflict (shift 16, reduce 11) on "ADD-operator" +30: shift/reduce conflict (shift 17, reduce 11) on "SUB-operator" +30: shift/reduce conflict (shift 18, reduce 11) on "MUL-operator" +30: shift/reduce conflict (shift 19, reduce 11) on "DIV-operator" +30: shift/reduce conflict (shift 20, reduce 11) on "MOD-operator" +30: shift/reduce conflict (shift 21, reduce 11) on "AND-operator" +30: shift/reduce conflict (shift 22, reduce 11) on '|' +state 30 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr "MOD-operator" expr . (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 11 + ')' reduce 11 + + +31: shift/reduce conflict (shift 16, reduce 12) on "ADD-operator" +31: shift/reduce conflict (shift 17, reduce 12) on "SUB-operator" +31: shift/reduce conflict (shift 18, reduce 12) on "MUL-operator" +31: shift/reduce conflict (shift 19, reduce 12) on "DIV-operator" +31: shift/reduce conflict (shift 20, reduce 12) on "MOD-operator" +31: shift/reduce conflict (shift 21, reduce 12) on "AND-operator" +31: shift/reduce conflict (shift 22, reduce 12) on '|' +state 31 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr "AND-operator" expr . (12) + expr : expr . '|' expr (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' shift 22 + '\n' reduce 12 + ')' reduce 12 + + +32: shift/reduce conflict (shift 16, reduce 13) on "ADD-operator" +32: shift/reduce conflict (shift 17, reduce 13) on "SUB-operator" +32: shift/reduce conflict (shift 18, reduce 13) on "MUL-operator" +32: shift/reduce conflict (shift 19, reduce 13) on "DIV-operator" +32: shift/reduce conflict (shift 20, reduce 13) on "MOD-operator" +32: shift/reduce conflict (shift 21, reduce 13) on "AND-operator" +state 32 + expr : expr . "ADD-operator" expr (7) + expr : expr . "SUB-operator" expr (8) + expr : expr . "MUL-operator" expr (9) + expr : expr . "DIV-operator" expr (10) + expr : expr . "MOD-operator" expr (11) + expr : expr . "AND-operator" expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + "ADD-operator" shift 16 + "SUB-operator" shift 17 + "MUL-operator" shift 18 + "DIV-operator" shift 19 + "MOD-operator" shift 20 + "AND-operator" shift 21 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +State 12 contains 6 shift/reduce conflicts. +State 26 contains 7 shift/reduce conflicts. +State 27 contains 7 shift/reduce conflicts. +State 28 contains 7 shift/reduce conflicts. +State 29 contains 7 shift/reduce conflicts. +State 30 contains 7 shift/reduce conflicts. +State 31 contains 7 shift/reduce conflicts. +State 32 contains 6 shift/reduce conflicts. + + +28 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 OP_ADD + 3 258 "ADD-operator" + 4 259 OP_SUB + 5 260 "SUB-operator" + 6 261 OP_MUL + 7 262 "MUL-operator" + 8 263 OP_DIV + 9 264 "DIV-operator" + 10 265 OP_MOD + 11 266 "MOD-operator" + 12 267 OP_AND + 13 268 "AND-operator" + 14 269 DIGIT + 15 270 LETTER + 16 124 '|' + 17 38 '&' + 18 43 '+' + 19 45 '-' + 20 42 '*' + 21 47 '/' + 22 37 '%' + 23 271 UMINUS + 24 10 '\n' + 25 61 '=' + 26 40 '(' + 27 41 ')' + 28 272 $accept + 29 273 list + 30 274 stat + 31 275 expr + 32 276 number diff --git a/contrib/byacc/test/btyacc/quote_calc4.tab.c b/contrib/byacc/test/btyacc/quote_calc4.tab.c new file mode 100644 index 000000000..59e6d1f4f --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4.tab.c @@ -0,0 +1,1446 @@ +/* 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 quote_calc4_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex quote_calc4_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror quote_calc4_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar quote_calc4_char +#endif /* yychar */ + +#ifndef yyval +#define yyval quote_calc4_val +#endif /* yyval */ + +#ifndef yylval +#define yylval quote_calc4_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug quote_calc4_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs quote_calc4_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag quote_calc4_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs quote_calc4_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen quote_calc4_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred quote_calc4_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos quote_calc4_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto quote_calc4_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex quote_calc4_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex quote_calc4_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex quote_calc4_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable quote_calc4_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck quote_calc4_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname quote_calc4_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule quote_calc4_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex quote_calc4_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable quote_calc4_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "quote_calc4_" + +#define YYPURE 0 + +#line 2 "quote_calc4.y" +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +#line 131 "quote_calc4.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 OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT quote_calc4_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT quote_calc4_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT quote_calc4_defred[] = { 1, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, + 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, + 0, 0, +}; +static const YYINT quote_calc4_stos[] = { 0, + 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, + 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, + 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, + 275, 275, +}; +static const YYINT quote_calc4_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT quote_calc4_sindex[] = { 0, + -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, + 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, + -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, + -121, -243, +}; +static const YYINT quote_calc4_rindex[] = { 0, + 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, + 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, + 3, -4, +}; +#if YYBTYACC +static const YYINT quote_calc4_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 quote_calc4_gindex[] = { 0, + 0, 42, 0, +}; +#define YYTABLESIZE 259 +static const YYINT quote_calc4_table[] = { 16, + 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, + 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, + 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, + 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 0, 17, 0, + 18, 0, 19, 0, 20, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 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, 0, 0, + 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, + 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, + 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, 15, +}; +static const YYINT quote_calc4_check[] = { 10, + 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, + 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, + 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, + 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, + -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, + -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 258, -1, 260, -1, + 262, -1, 264, -1, 266, -1, 268, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -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, -1, -1, + -1, 260, -1, 260, -1, -1, -1, -1, -1, -1, + 269, 270, 269, 270, 258, -1, 260, -1, 262, -1, + 264, -1, 266, -1, 268, -1, -1, 258, 258, 260, + 260, 262, 262, 264, 264, 266, 266, 268, 268, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const quote_calc4_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","OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", +"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS","$accept","list","stat", +"expr","number","illegal-symbol", +}; +static const char *const quote_calc4_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr \"ADD-operator\" expr", +"expr : expr \"SUB-operator\" expr", +"expr : expr \"MUL-operator\" expr", +"expr : expr \"DIV-operator\" expr", +"expr : expr \"MOD-operator\" expr", +"expr : expr \"AND-operator\" expr", +"expr : expr '|' expr", +"expr : \"SUB-operator\" expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 73 "quote_calc4.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 495 "quote_calc4.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc4.y" + { yyerrok ; } +break; +case 4: +#line 39 "quote_calc4.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "quote_calc4.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "quote_calc4.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "quote_calc4.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "quote_calc4.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "quote_calc4.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "quote_calc4.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "quote_calc4.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "quote_calc4.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "quote_calc4.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "quote_calc4.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "quote_calc4.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "quote_calc4.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "quote_calc4.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1212 "quote_calc4.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/quote_calc4.tab.h b/contrib/byacc/test/btyacc/quote_calc4.tab.h new file mode 100644 index 000000000..9279e7019 --- /dev/null +++ b/contrib/byacc/test/btyacc/quote_calc4.tab.h @@ -0,0 +1,14 @@ +#ifndef _quote_calc4__defines_h_ +#define _quote_calc4__defines_h_ + +#define OP_ADD 257 +#define OP_SUB 259 +#define OP_MUL 261 +#define OP_DIV 263 +#define OP_MOD 265 +#define OP_AND 267 +#define DIGIT 269 +#define LETTER 270 +#define UMINUS 271 + +#endif /* _quote_calc4__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/rename_debug.c b/contrib/byacc/test/btyacc/rename_debug.c new file mode 100644 index 000000000..330e725a4 --- /dev/null +++ b/contrib/byacc/test/btyacc/rename_debug.c @@ -0,0 +1,1121 @@ +/* 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" +#line 20 "rename_debug.c" +#include "rename_debug.i" +#include "rename_debug.h" +typedef short YYINT; +static const YYINT yylhs[] = { -1, + 0, +}; +static const YYINT yylen[] = { 2, + 1, +}; +static const YYINT yydefred[] = { 0, + 1, 0, +}; +static const YYINT yystos[] = { 0, + 256, 258, +}; +static const YYINT yydgoto[] = { 2, +}; +static const YYINT yysindex[] = { -256, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT yycindex[] = { 0, + 0, 0, +}; +#endif +static const YYINT yygindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT yytable[] = { 1, +}; +static const YYINT yycheck[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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", +}; +static const char *const yyrule[] = { +"$accept : S", +"S : error", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 12 "code_debug.y" + +#include + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 232 "rename_debug.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/rename_debug.error b/contrib/byacc/test/btyacc/rename_debug.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/btyacc/rename_debug.h b/contrib/byacc/test/btyacc/rename_debug.h new file mode 100644 index 000000000..ba44e7d75 --- /dev/null +++ b/contrib/byacc/test/btyacc/rename_debug.h @@ -0,0 +1,6 @@ +#ifndef _yy_defines_h_ +#define _yy_defines_h_ + +#define YYERRCODE 256 + +#endif /* _yy_defines_h_ */ diff --git a/contrib/byacc/test/btyacc/rename_debug.i b/contrib/byacc/test/btyacc/rename_debug.i new file mode 100644 index 000000000..b8f2144e1 --- /dev/null +++ b/contrib/byacc/test/btyacc/rename_debug.i @@ -0,0 +1,60 @@ +#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/contrib/byacc/test/btyacc/rename_debug.output b/contrib/byacc/test/btyacc/rename_debug.output new file mode 100644 index 000000000..1e56c214a --- /dev/null +++ b/contrib/byacc/test/btyacc/rename_debug.output @@ -0,0 +1,34 @@ + 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/contrib/byacc/test/btyacc/varsyntax_calc1.error b/contrib/byacc/test/btyacc/varsyntax_calc1.error new file mode 100644 index 000000000..9c1f7152c --- /dev/null +++ b/contrib/byacc/test/btyacc/varsyntax_calc1.error @@ -0,0 +1,2 @@ +YACC: 2 rules never reduced +YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/contrib/byacc/test/btyacc/varsyntax_calc1.output b/contrib/byacc/test/btyacc/varsyntax_calc1.output new file mode 100644 index 000000000..d6a869f6d --- /dev/null +++ b/contrib/byacc/test/btyacc/varsyntax_calc1.output @@ -0,0 +1,900 @@ + 0 $accept : line $end + + 1 lines : + 2 | lines line + + 3 line : dexp '\n' + 4 | vexp '\n' + 5 | DREG '=' dexp '\n' + 6 | VREG '=' vexp '\n' + 7 | error '\n' + + 8 dexp : CONST + 9 | DREG + 10 | dexp '+' dexp + 11 | dexp '-' dexp + 12 | dexp '*' dexp + 13 | dexp '/' dexp + 14 | '-' dexp + 15 | '(' dexp ')' + + 16 vexp : dexp + 17 | '(' dexp ',' dexp ')' + 18 | VREG + 19 | vexp '+' vexp + 20 | dexp '+' vexp + 21 | vexp '-' vexp + 22 | dexp '-' vexp + 23 | vexp '*' vexp + 24 | dexp '*' vexp + 25 | vexp '/' vexp + 26 | dexp '/' vexp + 27 | '-' vexp + 28 | '(' vexp ')' + +state 0 + $accept : . line $end (0) + + error shift 1 + DREG shift 2 + VREG shift 3 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + line goto 7 + dexp goto 8 + vexp goto 9 + + +state 1 + line : error . '\n' (7) + + '\n' shift 10 + . error + + +state 2 + line : DREG . '=' dexp '\n' (5) + dexp : DREG . (9) + + '=' shift 11 + '+' reduce 9 + '-' reduce 9 + '*' reduce 9 + '/' reduce 9 + '\n' reduce 9 + + +state 3 + line : VREG . '=' vexp '\n' (6) + vexp : VREG . (18) + + '=' shift 12 + '+' reduce 18 + '-' reduce 18 + '*' reduce 18 + '/' reduce 18 + '\n' reduce 18 + + +state 4 + dexp : CONST . (8) + + . reduce 8 + + +state 5 + dexp : '-' . dexp (14) + vexp : '-' . vexp (27) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 15 + vexp goto 16 + + +state 6 + dexp : '(' . dexp ')' (15) + vexp : '(' . dexp ',' dexp ')' (17) + vexp : '(' . vexp ')' (28) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 17 + vexp goto 18 + + +state 7 + $accept : line . $end (0) + + $end accept + + +8: shift/reduce conflict (shift 19, reduce 16) on '+' +8: shift/reduce conflict (shift 20, reduce 16) on '-' +8: shift/reduce conflict (shift 21, reduce 16) on '*' +8: shift/reduce conflict (shift 22, reduce 16) on '/' +8: shift/reduce conflict (shift 23, reduce 16) on '\n' +state 8 + line : dexp . '\n' (3) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + '\n' shift 23 + + +state 9 + line : vexp . '\n' (4) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' shift 28 + . error + + +state 10 + line : error '\n' . (7) + + . reduce 7 + + +state 11 + line : DREG '=' . dexp '\n' (5) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 31 + + +state 12 + line : VREG '=' . vexp '\n' (6) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 33 + + +state 13 + dexp : DREG . (9) + + . reduce 9 + + +state 14 + vexp : VREG . (18) + + . reduce 18 + + +15: reduce/reduce conflict (reduce 14, reduce 16) on '+' +15: reduce/reduce conflict (reduce 14, reduce 16) on '-' +15: reduce/reduce conflict (reduce 14, reduce 16) on '*' +15: reduce/reduce conflict (reduce 14, reduce 16) on '/' +15: reduce/reduce conflict (reduce 14, reduce 16) on '\n' +15: reduce/reduce conflict (reduce 14, reduce 16) on ')' +state 15 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 14 + + +state 16 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '-' vexp . (27) + + . reduce 27 + + +17: shift/reduce conflict (shift 19, reduce 16) on '+' +17: shift/reduce conflict (shift 20, reduce 16) on '-' +17: shift/reduce conflict (shift 21, reduce 16) on '*' +17: shift/reduce conflict (shift 22, reduce 16) on '/' +17: shift/reduce conflict (shift 34, reduce 16) on ')' +state 17 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + vexp : dexp . (16) + vexp : '(' dexp . ',' dexp ')' (17) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + ')' shift 34 + ',' shift 35 + + +state 18 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '(' vexp . ')' (28) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + ')' shift 36 + . error + + +state 19 + dexp : dexp '+' . dexp (10) + vexp : dexp '+' . vexp (20) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 37 + vexp goto 38 + + +state 20 + dexp : dexp '-' . dexp (11) + vexp : dexp '-' . vexp (22) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 39 + vexp goto 40 + + +state 21 + dexp : dexp '*' . dexp (12) + vexp : dexp '*' . vexp (24) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 41 + vexp goto 42 + + +state 22 + dexp : dexp '/' . dexp (13) + vexp : dexp '/' . vexp (26) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 43 + vexp goto 44 + + +state 23 + line : dexp '\n' . (3) + + . reduce 3 + + +state 24 + vexp : vexp '+' . vexp (19) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 45 + + +state 25 + vexp : vexp '-' . vexp (21) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 46 + + +state 26 + vexp : vexp '*' . vexp (23) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 47 + + +state 27 + vexp : vexp '/' . vexp (25) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 48 + + +state 28 + line : vexp '\n' . (4) + + . reduce 4 + + +state 29 + dexp : '-' . dexp (14) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 49 + + +state 30 + dexp : '(' . dexp ')' (15) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 50 + + +state 31 + line : DREG '=' dexp . '\n' (5) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + '\n' shift 55 + . error + + +32: shift/reduce conflict (shift 19, reduce 16) on '+' +32: shift/reduce conflict (shift 20, reduce 16) on '-' +32: shift/reduce conflict (shift 21, reduce 16) on '*' +32: shift/reduce conflict (shift 22, reduce 16) on '/' +state 32 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + '\n' reduce 16 + ')' reduce 16 + + +state 33 + line : VREG '=' vexp . '\n' (6) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' shift 56 + . error + + +state 34 + dexp : '(' dexp ')' . (15) + + . reduce 15 + + +state 35 + vexp : '(' dexp ',' . dexp ')' (17) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 57 + + +state 36 + vexp : '(' vexp ')' . (28) + + . reduce 28 + + +37: reduce/reduce conflict (reduce 10, reduce 16) on '+' +37: reduce/reduce conflict (reduce 10, reduce 16) on '-' +37: shift/reduce conflict (shift 21, reduce 16) on '*' +37: shift/reduce conflict (shift 22, reduce 16) on '/' +37: reduce/reduce conflict (reduce 10, reduce 16) on '\n' +37: reduce/reduce conflict (reduce 10, reduce 16) on ')' +state 37 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' shift 21 + '/' shift 22 + '+' reduce 10 + '-' reduce 10 + '\n' reduce 10 + ')' reduce 10 + ',' reduce 10 + + +state 38 + vexp : vexp . '+' vexp (19) + vexp : dexp '+' vexp . (20) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 20 + '-' reduce 20 + '\n' reduce 20 + ')' reduce 20 + + +39: reduce/reduce conflict (reduce 11, reduce 16) on '+' +39: reduce/reduce conflict (reduce 11, reduce 16) on '-' +39: shift/reduce conflict (shift 21, reduce 16) on '*' +39: shift/reduce conflict (shift 22, reduce 16) on '/' +39: reduce/reduce conflict (reduce 11, reduce 16) on '\n' +39: reduce/reduce conflict (reduce 11, reduce 16) on ')' +state 39 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' shift 21 + '/' shift 22 + '+' reduce 11 + '-' reduce 11 + '\n' reduce 11 + ')' reduce 11 + ',' reduce 11 + + +state 40 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : dexp '-' vexp . (22) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 22 + '-' reduce 22 + '\n' reduce 22 + ')' reduce 22 + + +41: reduce/reduce conflict (reduce 12, reduce 16) on '+' +41: reduce/reduce conflict (reduce 12, reduce 16) on '-' +41: reduce/reduce conflict (reduce 12, reduce 16) on '*' +41: reduce/reduce conflict (reduce 12, reduce 16) on '/' +41: reduce/reduce conflict (reduce 12, reduce 16) on '\n' +41: reduce/reduce conflict (reduce 12, reduce 16) on ')' +state 41 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 12 + + +state 42 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : dexp '*' vexp . (24) + vexp : vexp . '/' vexp (25) + + . reduce 24 + + +43: reduce/reduce conflict (reduce 13, reduce 16) on '+' +43: reduce/reduce conflict (reduce 13, reduce 16) on '-' +43: reduce/reduce conflict (reduce 13, reduce 16) on '*' +43: reduce/reduce conflict (reduce 13, reduce 16) on '/' +43: reduce/reduce conflict (reduce 13, reduce 16) on '\n' +43: reduce/reduce conflict (reduce 13, reduce 16) on ')' +state 43 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 13 + + +state 44 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : dexp '/' vexp . (26) + + . reduce 26 + + +state 45 + vexp : vexp . '+' vexp (19) + vexp : vexp '+' vexp . (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 19 + '-' reduce 19 + '\n' reduce 19 + ')' reduce 19 + + +state 46 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp '-' vexp . (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 21 + '-' reduce 21 + '\n' reduce 21 + ')' reduce 21 + + +state 47 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp '*' vexp . (23) + vexp : vexp . '/' vexp (25) + + . reduce 23 + + +state 48 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : vexp '/' vexp . (25) + + . reduce 25 + + +state 49 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + + . reduce 14 + + +state 50 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 34 + . error + + +state 51 + dexp : dexp '+' . dexp (10) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 58 + + +state 52 + dexp : dexp '-' . dexp (11) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 59 + + +state 53 + dexp : dexp '*' . dexp (12) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 60 + + +state 54 + dexp : dexp '/' . dexp (13) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 61 + + +state 55 + line : DREG '=' dexp '\n' . (5) + + . reduce 5 + + +state 56 + line : VREG '=' vexp '\n' . (6) + + . reduce 6 + + +state 57 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : '(' dexp ',' dexp . ')' (17) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 62 + . error + + +state 58 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 10 + '-' reduce 10 + '\n' reduce 10 + ')' reduce 10 + + +state 59 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 11 + '-' reduce 11 + '\n' reduce 11 + ')' reduce 11 + + +state 60 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + + . reduce 12 + + +state 61 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + + . reduce 13 + + +state 62 + vexp : '(' dexp ',' dexp ')' . (17) + + . reduce 17 + + +Rules never reduced: + lines : (1) + lines : lines line (2) + + +State 8 contains 5 shift/reduce conflicts. +State 15 contains 6 reduce/reduce conflicts. +State 17 contains 5 shift/reduce conflicts. +State 32 contains 4 shift/reduce conflicts. +State 37 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 39 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 41 contains 6 reduce/reduce conflicts. +State 43 contains 6 reduce/reduce conflicts. + + +15 terminals, 5 nonterminals +29 grammar rules, 63 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DREG + 3 258 VREG + 4 259 CONST + 5 43 '+' + 6 45 '-' + 7 42 '*' + 8 47 '/' + 9 260 UMINUS + 10 10 '\n' + 11 61 '=' + 12 40 '(' + 13 41 ')' + 14 44 ',' + 15 261 $accept + 16 262 line + 17 263 dexp + 18 264 vexp + 19 265 lines diff --git a/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c new file mode 100644 index 000000000..afab81092 --- /dev/null +++ b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c @@ -0,0 +1,1678 @@ +/* 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 +#ident "check variant syntax features" +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse varsyntax_calc1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex varsyntax_calc1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror varsyntax_calc1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar varsyntax_calc1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval varsyntax_calc1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval varsyntax_calc1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug varsyntax_calc1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs varsyntax_calc1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag varsyntax_calc1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs varsyntax_calc1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen varsyntax_calc1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred varsyntax_calc1_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos varsyntax_calc1_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto varsyntax_calc1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex varsyntax_calc1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex varsyntax_calc1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex varsyntax_calc1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable varsyntax_calc1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck varsyntax_calc1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname varsyntax_calc1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule varsyntax_calc1_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex varsyntax_calc1_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable varsyntax_calc1_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "varsyntax_calc1_" + +#define YYPURE 0 + +#line 3 "varsyntax_calc1.y" + +/* http://dinosaur.compilertools.net/yacc/index.html * /*/ + +#include +#include +#include +#include + +typedef struct interval +{ + double lo, hi; +} +INTERVAL; + +INTERVAL vmul(double, double, INTERVAL); +INTERVAL vdiv(double, double, INTERVAL); + +extern int yylex(void); +static void yyerror(const char *s); + +int dcheck(INTERVAL); + +double dreg[26]; +INTERVAL vreg[26]; + +#line 32 "varsyntax_calc1.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; /* dreg & vreg array index values*/ + double dval; /* floating point values*/ + INTERVAL vval; /* interval values*/ +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 162 "varsyntax_calc1.tab.c" + +/* 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 DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT varsyntax_calc1_lhs[] = { -1, + 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, +}; +static const YYINT varsyntax_calc1_len[] = { 2, + 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, + 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 3, +}; +static const YYINT varsyntax_calc1_defred[] = { 0, + 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, + 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, + 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, + 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, + 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, + 13, 17, +}; +static const YYINT varsyntax_calc1_stos[] = { 0, + 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, + 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, + 42, 47, 10, 43, 45, 42, 47, 10, 45, 40, + 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, + 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, + 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, + 263, 41, +}; +static const YYINT varsyntax_calc1_dgoto[] = { 7, + 32, 9, 0, +}; +static const YYINT varsyntax_calc1_sindex[] = { -40, + -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, + -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, + -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, + 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, + 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, + -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, + 0, 0, +}; +static const YYINT varsyntax_calc1_rindex[] = { 0, + 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, + 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT varsyntax_calc1_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, 0, 0, 0, 0, 0, 0, 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 varsyntax_calc1_gindex[] = { 0, + 4, 124, 0, +}; +#define YYTABLESIZE 225 +static const YYINT varsyntax_calc1_table[] = { 6, + 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, + 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, + 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, + 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, + 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, + 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, + 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, + 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, + 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, + 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, + 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, + 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, + 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, + 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, + 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, + 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, + 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, + 14, 4, 13, 0, 4, +}; +static const YYINT varsyntax_calc1_check[] = { 40, + 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, + 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, + -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, + 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, + 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, + -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, + 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, + 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, + 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, + 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, + 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, + 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, + 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, + 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, + -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, + 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, + 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, + -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -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, 259, 257, + 258, 259, 257, -1, 259, +}; +#define YYFINAL 7 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 260 +#define YYUNDFTOKEN 266 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const varsyntax_calc1_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,0,0, +"error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines", +"illegal-symbol", +}; +static const char *const varsyntax_calc1_rule[] = { +"$accept : line", +"lines :", +"lines : lines line", +"line : dexp '\\n'", +"line : vexp '\\n'", +"line : DREG '=' dexp '\\n'", +"line : VREG '=' vexp '\\n'", +"line : error '\\n'", +"dexp : CONST", +"dexp : DREG", +"dexp : dexp '+' dexp", +"dexp : dexp '-' dexp", +"dexp : dexp '*' dexp", +"dexp : dexp '/' dexp", +"dexp : '-' dexp", +"dexp : '(' dexp ')'", +"vexp : dexp", +"vexp : '(' dexp ',' dexp ')'", +"vexp : VREG", +"vexp : vexp '+' vexp", +"vexp : dexp '+' vexp", +"vexp : vexp '-' vexp", +"vexp : dexp '-' vexp", +"vexp : vexp '*' vexp", +"vexp : dexp '*' vexp", +"vexp : vexp '/' vexp", +"vexp : dexp '/' vexp", +"vexp : '-' vexp", +"vexp : '(' vexp ')'", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +#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 = ((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; \ + } \ + 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; \ + } \ +} 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; + short *s_base; + short *s_mark; + short *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 short *yylexp = 0; + +static short *yylexemes = 0; +#endif /* YYBTYACC */ +#line 178 "varsyntax_calc1.y" + /* beginning of subroutines section */ + +#define BSZ 50 /* buffer size for floating point numbers */ + + /* lexical analysis */ + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + int c; + + while ((c = getchar()) == ' ') + { /* skip over blanks */ + } + + if (isupper(c)) + { + yylval.ival = c - 'A'; + return (VREG); + } + if (islower(c)) + { + yylval.ival = c - 'a'; + return (DREG); + } + + if (isdigit(c) || c == '.') + { + /* gobble up digits, points, exponents */ + char buf[BSZ + 1], *cp = buf; + int dot = 0, expr = 0; + + for (; (cp - buf) < BSZ; ++cp, c = getchar()) + { + + *cp = (char) c; + if (isdigit(c)) + continue; + if (c == '.') + { + if (dot++ || expr) + return ('.'); /* will cause syntax error */ + continue; + } + + if (c == 'e') + { + if (expr++) + return ('e'); /* will cause syntax error */ + continue; + } + + /* end of number */ + break; + } + *cp = '\0'; + + if ((cp - buf) >= BSZ) + printf("constant too long: truncated\n"); + else + ungetc(c, stdin); /* push back last char read */ + yylval.dval = atof(buf); + return (CONST); + } + return (c); +} + +static INTERVAL +hilo(double a, double b, double c, double d) +{ + /* returns the smallest interval containing a, b, c, and d */ + /* used by *, / routines */ + INTERVAL v; + + if (a > b) + { + v.hi = a; + v.lo = b; + } + else + { + v.hi = b; + v.lo = a; + } + + if (c > d) + { + if (c > v.hi) + v.hi = c; + if (d < v.lo) + v.lo = d; + } + else + { + if (d > v.hi) + v.hi = d; + if (c < v.lo) + v.lo = c; + } + return (v); +} + +INTERVAL +vmul(double a, double b, INTERVAL v) +{ + return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); +} + +int +dcheck(INTERVAL v) +{ + if (v.hi >= 0. && v.lo <= 0.) + { + printf("divisor interval contains 0.\n"); + return (1); + } + return (0); +} + +INTERVAL +vdiv(double a, double b, INTERVAL v) +{ + return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); +} +#line 624 "varsyntax_calc1.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 /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 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 = (short *)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 = (short *) malloc(size * sizeof(short)); + 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[2]; /* position of error start & end */ +#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 YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + 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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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 = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + 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 = (short) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = 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 = (short) 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; + +yyerrlab: + 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#endif + yyerrctx->lexeme = 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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[0] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; +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[1] = 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[0] = *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) + { + yys = yyname[YYTRANSLATE(yychar)]; + 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[1-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]; + } +#endif + + switch (yyn) + { +case 3: +#line 59 "varsyntax_calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[-1].dval); + } +break; +case 4: +#line 63 "varsyntax_calc1.y" + { + (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); + } +break; +case 5: +#line 67 "varsyntax_calc1.y" + { + dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; + } +break; +case 6: +#line 71 "varsyntax_calc1.y" + { + vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; + } +break; +case 7: +#line 75 "varsyntax_calc1.y" + { + yyerrok; + } +break; +case 9: +#line 82 "varsyntax_calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ + } +break; +case 10: +#line 86 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +break; +case 11: +#line 90 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +break; +case 12: +#line 94 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +break; +case 13: +#line 98 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +break; +case 14: +#line 102 "varsyntax_calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +break; +case 15: +#line 106 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +break; +case 16: +#line 112 "varsyntax_calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +break; +case 17: +#line 116 "varsyntax_calc1.y" + { + yyval.vval.lo = yystack.l_mark[-3].dval; + yyval.vval.hi = yystack.l_mark[-1].dval; + if ( yyval.vval.lo > yyval.vval.hi ) + { + (void) printf("interval out of order\n"); + YYERROR; + } + } +break; +case 18: +#line 126 "varsyntax_calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +break; +case 19: +#line 130 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; + } +break; +case 20: +#line 135 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; + } +break; +case 21: +#line 140 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; + } +break; +case 22: +#line 145 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; + } +break; +case 23: +#line 150 "varsyntax_calc1.y" + { + yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 24: +#line 154 "varsyntax_calc1.y" + { + yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 25: +#line 158 "varsyntax_calc1.y" + { + if (dcheck(yystack.l_mark[0].vval)) YYERROR; + yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 26: +#line 163 "varsyntax_calc1.y" + { + if (dcheck ( yystack.l_mark[0].vval )) YYERROR; + yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 27: +#line 168 "varsyntax_calc1.y" + { + yyval.vval.hi = -yystack.l_mark[0].vval.lo; + yyval.vval.lo = -yystack.l_mark[0].vval.hi; + } +break; +case 28: +#line 173 "varsyntax_calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +break; +#line 1444 "varsyntax_calc1.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 */ + int p = yylvp - yylvals; + int s = 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 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 = (short) 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 ((yychar = YYLEX) < 0) yychar = YYEOF; */ +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + fprintf(stderr, "%s[%d]: state %d, reading %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 = (short) 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, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + 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)); +#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)); +#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/contrib/byacc/test/btyacc/varsyntax_calc1.tab.h b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.h new file mode 100644 index 000000000..49e269cdb --- /dev/null +++ b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.h @@ -0,0 +1,23 @@ +#ifndef _varsyntax_calc1__defines_h_ +#define _varsyntax_calc1__defines_h_ + +#define DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; /* dreg & vreg array index values*/ + double dval; /* floating point values*/ + INTERVAL vval; /* interval values*/ +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE varsyntax_calc1_lval; + +#endif /* _varsyntax_calc1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc_calc1.y b/contrib/byacc/test/btyacc_calc1.y new file mode 100644 index 000000000..0c6311c88 --- /dev/null +++ b/contrib/byacc/test/btyacc_calc1.y @@ -0,0 +1,324 @@ +%PURE_PARSER +%{ + +/* http://dinosaur.compilertools.net/yacc/index.html */ + +#include +#include +#include +#include + +typedef struct interval +{ + double lo, hi; +} +INTERVAL; + +INTERVAL vmul(double, double, INTERVAL); +INTERVAL vdiv(double, double, INTERVAL); + +int dcheck(INTERVAL); + +double dreg[26]; +INTERVAL vreg[26]; + +%} +%expect 17 + +%start lines +%union +{ + int ival; + double dval; + INTERVAL vval; +} + +%token DREG VREG /* indices into dreg, vreg arrays */ +%token CONST /* floating point constant */ + +%type dexp /* expression */ +%type vexp /* interval expression */ + + /* precedence information about the operators */ + +%left '+' '-' +%left '*' '/' +%right UMINUS /* precedence for unary minus */ + +%% /* beginning of rules section */ + +lines : /* empty */ + | lines line '\n' [YYVALID;] + | lines error '\n' [YYVALID;] + { + yyerrok; + } + ; + +line : dexp + { + (void) printf("%15.8f\n", $1); + } + | vexp + { + (void) printf("(%15.8f, %15.8f)\n", $1.lo, $1.hi); + } + | DREG '=' dexp + { + dreg[$1] = $3; + } + | VREG '=' vexp + { + vreg[$1] = $3; + } + ; + +dexp : CONST + | DREG + { + $$ = dreg[$1]; + } + | dexp '+' dexp + { + $$ = $1 + $3; + } + | dexp '-' dexp + { + $$ = $1 - $3; + } + | dexp '*' dexp + { + $$ = $1 * $3; + } + | dexp '/' dexp + { + $$ = $1 / $3; + } + | '-' dexp %prec UMINUS + { + $$ = -$2; + } + | '(' dexp ')' + { + $$ = $2; + } + ; + +vexp : dexp + { + $$.hi = $$.lo = $1; + } + | '(' dexp ',' dexp ')' + { + $$.lo = $2; + $$.hi = $4; + if ( $$.lo > $$.hi ) + { + (void) printf("interval out of order\n"); + YYERROR; + } + } + | VREG + { + $$ = vreg[$1]; + } + | vexp '+' vexp + { + $$.hi = $1.hi + $3.hi; + $$.lo = $1.lo + $3.lo; + } + | dexp '+' vexp + { + $$.hi = $1 + $3.hi; + $$.lo = $1 + $3.lo; + } + | vexp '-' vexp + { + $$.hi = $1.hi - $3.lo; + $$.lo = $1.lo - $3.hi; + } + | dexp '-' vexp + { + $$.hi = $1 - $3.lo; + $$.lo = $1 - $3.hi; + } + | vexp '*' vexp + { + $$ = vmul( $1.lo, $1.hi, $3 ); + } + | dexp '*' vexp + { + $$ = vmul ($1, $1, $3 ); + } + | vexp '/' vexp + { + if (dcheck($3)) YYERROR; + $$ = vdiv ( $1.lo, $1.hi, $3 ); + } + | dexp '/' vexp + { + if (dcheck ( $3 )) YYERROR; + $$ = vdiv ($1, $1, $3 ); + } + | '-' vexp %prec UMINUS + { + $$.hi = -$2.lo; + $$.lo = -$2.hi; + } + | '(' vexp ')' + { + $$ = $2; + } + ; + +%% /* beginning of subroutines section */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +#define BSZ 50 /* buffer size for floating point numbers */ + +static void +YYERROR_DECL() +{ + fprintf(stderr, "%s\n", s); +} + + /* lexical analysis */ + +static int +YYLEX_DECL() +{ + int c; + + while ((c = getchar()) == ' ') + { /* skip over blanks */ + } + + if (isupper(c)) + { +#if YYPURE + (*yylval).ival = c - 'A'; +#else + yylval.ival = c - 'A'; +#endif + return (VREG); + } + if (islower(c)) + { +#if YYPURE + (*yylval).ival = c - 'a'; +#else + yylval.ival = c - 'a'; +#endif + return (DREG); + } + + if (isdigit(c) || c == '.') + { + /* gobble up digits, points, exponents */ + char buf[BSZ + 1], *cp = buf; + int dot = 0, expr = 0; + + for (; (cp - buf) < BSZ; ++cp, c = getchar()) + { + + *cp = (char) c; + if (isdigit(c)) + continue; + if (c == '.') + { + if (dot++ || expr) + return ('.'); /* will cause syntax error */ + continue; + } + + if (c == 'e') + { + if (expr++) + return ('e'); /* will cause syntax error */ + continue; + } + + /* end of number */ + break; + } + *cp = '\0'; + + if ((cp - buf) >= BSZ) + printf("constant too long: truncated\n"); + else + ungetc(c, stdin); /* push back last char read */ +#if YYPURE + (*yylval).dval = atof(buf); +#else + yylval.dval = atof(buf); +#endif + return (CONST); + } + return (c); +} + +static INTERVAL +hilo(double a, double b, double c, double d) +{ + /* returns the smallest interval containing a, b, c, and d */ + /* used by *, / routines */ + INTERVAL v; + + if (a > b) + { + v.hi = a; + v.lo = b; + } + else + { + v.hi = b; + v.lo = a; + } + + if (c > d) + { + if (c > v.hi) + v.hi = c; + if (d < v.lo) + v.lo = d; + } + else + { + if (d > v.hi) + v.hi = d; + if (c < v.lo) + v.lo = c; + } + return (v); +} + +INTERVAL +vmul(double a, double b, INTERVAL v) +{ + return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); +} + +int +dcheck(INTERVAL v) +{ + if (v.hi >= 0. && v.lo <= 0.) + { + printf("divisor interval contains 0.\n"); + return (1); + } + return (0); +} + +INTERVAL +vdiv(double a, double b, INTERVAL v) +{ + return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); +} diff --git a/contrib/byacc/test/btyacc_demo.y b/contrib/byacc/test/btyacc_demo.y new file mode 100644 index 000000000..892434c8b --- /dev/null +++ b/contrib/byacc/test/btyacc_demo.y @@ -0,0 +1,226 @@ +/* + * demonstrate enhancements derived from btyacc: + * backtracking to resolve conflicts + * semantic disambiguation via []-actions invoking YYVALID & YYERROR + * %locations + * @$ & @N to refer to lhs & rhs symbol location + * %destructor + * syntactic suger for inherited attributes + * extension to %type to define inherited attribute type + */ + +%LOCATIONS + +%{ +/* dummy types just for compile check */ +typedef int Code; +typedef int Decl_List; +typedef int Expr; +typedef int Expr_List; +typedef int Scope; +typedef int Type; +enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF }; + +typedef unsigned char bool; +typedef struct Decl { + Scope *scope; + Type *type; + bool (*istype)(void); +} Decl; + +#include "btyacc_demo.tab.h" +#include +#include +%} + +%union { + Scope *scope; + Expr *expr; + Expr_List *elist; + Type *type; + Decl *decl; + Decl_List *dlist; + Code *code; + char *id; + }; + +%left '+' '-' +%left '*' '/' '%' +%nonassoc PREFIX +%nonassoc POSTFIX '(' '[' '.' + +%token ID +%token CONSTANT +%token EXTERN REGISTER STATIC CONST VOLATILE IF THEN ELSE CLCL + +%type expr() +%type decl() declarator_list(, ) + decl_list() +%type statement() statement_list() + block_statement() +%type declarator(, ) formal_arg() +%type decl_specs() decl_spec() typename() + cv_quals cv_qual +%type opt_scope() +%type formal_arg_list() nonempty_formal_arg_list() + +%destructor { // 'msg' is a 'char *' indicating the context of destructor invocation + printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n", + msg, + @$.first_line, @$.first_column, + @$.last_line, @$.last_column); + free($$->scope); free($$->type); } decl +%destructor { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", + msg, + @$.first_line, @$.first_column, + @$.last_line, @$.last_column); + free($$); } +%destructor { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", + msg, + @$.first_line, @$.first_column, + @$.last_line, @$.last_column); + free($$); } <*> +%destructor { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", + msg, + @$.first_line, @$.first_column, + @$.last_line, @$.last_column); + /* in this example, we don't know what to do here */ } <> + +%start input + +%% + +opt_scope($e): [ $$ = $e; ] + | CLCL [ $$ = global_scope; ] + | opt_scope ID CLCL [ Decl *d = lookup($1, $2); + if (!d || !d->scope) YYERROR; + $$ = d->scope; ] + ; + +typename($e): opt_scope ID + [ Decl *d = lookup($1, $2); + if (d == NULL || d->istype() == 0) YYERROR; + $$ = d->type; ] + ; + +input: decl_list(global_scope = new_scope(0)) ; +decl_list($e): | decl_list decl($e) ; +decl($e): + decl_specs declarator_list($e,$1) ';' [YYVALID;] + | decl_specs declarator($e,$1) block_statement(start_fn_def($e, $2)) + { /* demonstrate use of @$ & @N, although this is just the + default computation and so is not necessary */ + @$.first_line = @1.first_line; + @$.first_column = @1.first_column; + @$.last_line = @3.last_line; + @$.last_column = @3.last_column; + finish_fn_def($2, $3); } + ; + +decl_specs($e): + decl_spec [ $$ = $1; ] + | decl_specs decl_spec($e) [ $$ = type_combine($1, $2); ] + ; + +cv_quals: [ $$ = 0; ] + | cv_quals cv_qual [ $$ = type_combine($1, $2); ] + ; + +decl_spec($e): + cv_qual [ $$ = $1; ] + | typename [ $$ = $1; ] + | EXTERN [ $$ = bare_extern(); ] + | REGISTER [ $$ = bare_register(); ] + | STATIC [ $$ = bare_static(); ] + ; + +cv_qual: + CONST [ $$ = bare_const(); ] + | VOLATILE [ $$ = bare_volatile(); ] + ; + +declarator_list($e, $t): + declarator_list ',' declarator($e, $t) + | declarator + ; + +declarator($e, $t): + /* empty */ [ if (!$t) YYERROR; ] + { $$ = declare($e, 0, $t); } + | ID { $$ = declare($e, $1, $t); } + | '(' declarator($e, $t) ')' { $$ = $2; } + | '*' cv_quals declarator($e, $t) %prec PREFIX + { $$ = make_pointer($3, $2); } + | declarator '[' expr($e) ']' + { $$ = make_array($1->type, $3); } + | declarator '(' formal_arg_list($e) ')' cv_quals + { $$ = build_function($1, $3, $5); } + ; + +formal_arg_list($e): { $$ = 0; } + | nonempty_formal_arg_list { $$ = $1; } + ; +nonempty_formal_arg_list($e): + nonempty_formal_arg_list ',' formal_arg($e) { $$ = append_dlist($1, $3); } + | formal_arg { $$ = build_dlist($1); } + ; +formal_arg($e): + decl_specs declarator($e,$1) { $$ = $2; } + ; + +expr($e): + expr '+' expr($e) { $$ = build_expr($1, ADD, $3); } + | expr '-' expr($e) { $$ = build_expr($1, SUB, $3); } + | expr '*' expr($e) { $$ = build_expr($1, MUL, $3); } + | expr '%' expr($e) { $$ = build_expr($1, MOD, $3); } + | expr '/' expr($e) { $$ = build_expr($1, DIV, $3); } + | '*' expr($e) %prec PREFIX { $$ = build_expr(0, DEREF, $2); } + | ID { $$ = var_expr($e, $1); } + | CONSTANT { $$ = $1; } + ; + +statement($e): + decl { $$ = 0; } + | expr($e) ';' [YYVALID;] { $$ = build_expr_code($1); } + | IF '(' expr($e) ')' THEN statement($e) ELSE statement($e) [YYVALID;] + { $$ = build_if($3, $6, $8); } + | IF '(' expr($e) ')' THEN statement($e) [YYVALID;] + { $$ = build_if($3, $6, 0); } + | block_statement(new_scope($e)) [YYVALID;]{ $$ = $1; } + ; + +statement_list($e): { $$ = 0; } + | statement_list statement($e) { $$ = code_append($1, $2); } + ; + +block_statement($e): + '{' statement_list($e) '}' { $$ = $2; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); + +extern Scope *global_scope; + +extern Decl * lookup(Scope *scope, char *id); +extern Scope * new_scope(Scope *outer_scope); +extern Scope * start_fn_def(Scope *scope, Decl *fn_decl); +extern void finish_fn_def(Decl *fn_decl, Code *block); +extern Type * type_combine(Type *specs, Type *spec); +extern Type * bare_extern(void); +extern Type * bare_register(void); +extern Type * bare_static(void); +extern Type * bare_const(void); +extern Type * bare_volatile(void); +extern Decl * declare(Scope *scope, char *id, Type *type); +extern Decl * make_pointer(Decl *decl, Type *type); +extern Decl * make_array(Type *type, Expr *expr); +extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type); +extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl); +extern Decl_List * build_dlist(Decl *decl); +extern Expr * build_expr(Expr *left, enum Operator op, Expr *right); +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); diff --git a/contrib/byacc/test/calc2.y b/contrib/byacc/test/calc2.y index e742ff34c..d9193d087 100644 --- a/contrib/byacc/test/calc2.y +++ b/contrib/byacc/test/calc2.y @@ -88,9 +88,13 @@ main (void) return 0; } +#define UNUSED(x) ((void)(x)) + static void YYERROR_DECL() { + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ fprintf(stderr, "%s\n", s); } diff --git a/contrib/byacc/test/calc3.y b/contrib/byacc/test/calc3.y index 252faa961..2c9148e80 100644 --- a/contrib/byacc/test/calc3.y +++ b/contrib/byacc/test/calc3.y @@ -91,9 +91,13 @@ main (void) return 0; } +#define UNUSED(x) ((void)(x)) + static void YYERROR_DECL() { + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ fprintf(stderr, "%s\n", s); } diff --git a/contrib/byacc/test/code_debug.y b/contrib/byacc/test/code_debug.y new file mode 100644 index 000000000..bb7715676 --- /dev/null +++ b/contrib/byacc/test/code_debug.y @@ -0,0 +1,36 @@ +%{ + +#ifdef YYBISON +int yylex(void); +static void yyerror(const char *); +#endif + +%} +%% +S: error +%% + +#include + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/code_error.tab.c b/contrib/byacc/test/code_error.tab.c deleted file mode 100644 index eb4db1278..000000000 --- a/contrib/byacc/test/code_error.tab.c +++ /dev/null @@ -1,118 +0,0 @@ - -#ifndef yyparse -#define yyparse error_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex error_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror error_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar error_char -#endif /* yychar */ - -#ifndef yyval -#define yyval error_val -#endif /* yyval */ - -#ifndef yylval -#define yylval error_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug error_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs error_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag error_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs error_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen error_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred error_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto error_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex error_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex error_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex error_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable error_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck error_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname error_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule error_rule -#endif /* yyrule */ -#define YYPREFIX "error_" -const short error_lhs[] = { -1, - 0, -}; -const short error_len[] = { 2, - 1, -}; -const short error_defred[] = { 0, - 1, 0, -}; -const short error_dgoto[] = { 2, -}; -const short error_sindex[] = { -256, - 0, 0, -}; -const short error_rindex[] = { 0, - 0, 0, -}; -const short error_gindex[] = { 0, -}; -const short error_table[] = { 1, -}; -const short error_check[] = { 256, -}; -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#if YYDEBUG -const char *yyname[] = { - -"end-of-file", -}; -const char *yyrule[] = { -"$accept : S", -"S : error", - -}; -#endif diff --git a/contrib/byacc/test/empty.y b/contrib/byacc/test/empty.y new file mode 100644 index 000000000..2e60a743c --- /dev/null +++ b/contrib/byacc/test/empty.y @@ -0,0 +1,24 @@ +%{ +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +static int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif +%} +%% +start: ; + +%% + +#include + +static int +YYLEX_DECL() { + return -1; +} + +static void +YYERROR_DECL() { + printf("%s\n",s); +} diff --git a/contrib/byacc/test/err_inherit1.y b/contrib/byacc/test/err_inherit1.y new file mode 100644 index 000000000..6c16e17cd --- /dev/null +++ b/contrib/byacc/test/err_inherit1.y @@ -0,0 +1,64 @@ +%{ +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%type declaration namelist(, ) locnamelist() +%type class +%type type + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist($1, $2) + { $$ = $3; } + | type locnamelist($1) + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist($c, $t diff --git a/contrib/byacc/test/err_inherit2.y b/contrib/byacc/test/err_inherit2.y new file mode 100644 index 000000000..a39e2d0f1 --- /dev/null +++ b/contrib/byacc/test/err_inherit2.y @@ -0,0 +1,80 @@ +%{ +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%type declaration namelist(, ) locnamelist() +%type class +%type type + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist($1, $2) + { $$ = $3; } + | type locnamelist($1) + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist($c, $t, extra): namelist NAME + { $$->s = mksymbol($t, $c, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol($t, $c, $1); + $$->next = NULL; + } + ; + +locnamelist($t): namelist(cLOCAL, $t) + { $$ = $1; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/contrib/byacc/test/err_inherit3.y b/contrib/byacc/test/err_inherit3.y new file mode 100644 index 000000000..f52a5f7b6 --- /dev/null +++ b/contrib/byacc/test/err_inherit3.y @@ -0,0 +1,80 @@ +%{ +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%type declaration() namelist(, ) locnamelist() +%type class +%type type + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration($d): class type namelist($1, $2) + { $$ = $3; } + | type locnamelist($1) + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist: namelist($c) NAME + { $$->s = mksymbol($t, $c, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol($t, $c, $1); + $$->next = NULL; + } + ; + +locnamelist($t): namelist(cLOCAL, $t) + { $$ = $1; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/contrib/byacc/test/err_inherit4.y b/contrib/byacc/test/err_inherit4.y new file mode 100644 index 000000000..ed788d12c --- /dev/null +++ b/contrib/byacc/test/err_inherit4.y @@ -0,0 +1,82 @@ +%locations +%{ +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%type declaration namelist(, ) locnamelist() +%destructor { } +%type class +%type type + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist($1, $2) + { $$ = $3; } + | type locnamelist($1) + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist($c, $t): namelist NAME + { $$->s = mksymbol($t, $c, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol($t, $c, $1); + $$->next = NULL; + } + ; + +locnamelist($t): namelist + { $$ = $1; @$ = @2; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/contrib/byacc/test/err_inherit5.y b/contrib/byacc/test/err_inherit5.y new file mode 100644 index 000000000..56c5c7e4c --- /dev/null +++ b/contrib/byacc/test/err_inherit5.y @@ -0,0 +1,80 @@ +%{ +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%type declaration namelist(, ) locnamelist() +%type class +%type type + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist($1, $2) + { $$ = $3; } + | type locnamelist($1) + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist($c, $t): namelist NAME + { $$->s = mksymbol($t, $c, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol($t, $c, $1); + $$->next = NULL; + } + ; + +locnamelist($t): namelist(@1, $t) + { $$ = $1; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/contrib/byacc/test/err_syntax1.y b/contrib/byacc/test/err_syntax1.y new file mode 100644 index 000000000..27355207a --- /dev/null +++ b/contrib/byacc/test/err_syntax1.y @@ -0,0 +1,28 @@ + % { +int yylex(void); +static void yyerror(const char *); +%} +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax10.y b/contrib/byacc/test/err_syntax10.y new file mode 100644 index 000000000..581f8458d --- /dev/null +++ b/contrib/byacc/test/err_syntax10.y @@ -0,0 +1,32 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token '(' '*' '&' +%token '(' '*' '&' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax11.y b/contrib/byacc/test/err_syntax11.y new file mode 100644 index 000000000..81bdf6914 --- /dev/null +++ b/contrib/byacc/test/err_syntax11.y @@ -0,0 +1,32 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%left '|' +%right '|' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax12.y b/contrib/byacc/test/err_syntax12.y new file mode 100644 index 000000000..ae1a48c17 --- /dev/null +++ b/contrib/byacc/test/err_syntax12.y @@ -0,0 +1,32 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token text 123 +%token text 456 + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax13.y b/contrib/byacc/test/err_syntax13.y new file mode 100644 index 000000000..f28ed435e --- /dev/null +++ b/contrib/byacc/test/err_syntax13.y @@ -0,0 +1,32 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token text 123 +%start text + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax14.y b/contrib/byacc/test/err_syntax14.y new file mode 100644 index 000000000..43e4fc078 --- /dev/null +++ b/contrib/byacc/test/err_syntax14.y @@ -0,0 +1,32 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%start text +%start text2 + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax15.y b/contrib/byacc/test/err_syntax15.y new file mode 100644 index 000000000..88814c914 --- /dev/null +++ b/contrib/byacc/test/err_syntax15.y @@ -0,0 +1,32 @@ +%% +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%start text + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax16.y b/contrib/byacc/test/err_syntax16.y new file mode 100644 index 000000000..0479e8217 --- /dev/null +++ b/contrib/byacc/test/err_syntax16.y @@ -0,0 +1,40 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token second + +%% + +firstx + : '(' secondx + ; + +second : + ')' + ; + +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax17.y b/contrib/byacc/test/err_syntax17.y new file mode 100644 index 000000000..a5551c2f7 --- /dev/null +++ b/contrib/byacc/test/err_syntax17.y @@ -0,0 +1,30 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%% + +S: { error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax18.y b/contrib/byacc/test/err_syntax18.y new file mode 100644 index 000000000..1407af802 --- /dev/null +++ b/contrib/byacc/test/err_syntax18.y @@ -0,0 +1,33 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%% + +expr : '(' expr ')' + { $$ = $4; } + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax19.y b/contrib/byacc/test/err_syntax19.y new file mode 100644 index 000000000..e2ee5497a --- /dev/null +++ b/contrib/byacc/test/err_syntax19.y @@ -0,0 +1,33 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%% + +expr : '(' expr ')' + { $$ = $; } + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax2.y b/contrib/byacc/test/err_syntax2.y new file mode 100644 index 000000000..247511ebd --- /dev/null +++ b/contrib/byacc/test/err_syntax2.y @@ -0,0 +1,28 @@ +%{ /* +int yylex(void); +static void yyerror(const char *); +%} +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax20.y b/contrib/byacc/test/err_syntax20.y new file mode 100644 index 000000000..880e01817 --- /dev/null +++ b/contrib/byacc/test/err_syntax20.y @@ -0,0 +1,36 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%type expr +%type recur + +%% + +expr : '(' recur ')' + { $2 = 3; } + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax21.y b/contrib/byacc/test/err_syntax21.y new file mode 100644 index 000000000..ba6ec7080 --- /dev/null +++ b/contrib/byacc/test/err_syntax21.y @@ -0,0 +1,36 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%type expr +%type recur + +%% + +expr : '(' recur ')' + { foo( $$ = $0 ); } + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax22.y b/contrib/byacc/test/err_syntax22.y new file mode 100644 index 000000000..e92decbf5 --- /dev/null +++ b/contrib/byacc/test/err_syntax22.y @@ -0,0 +1,44 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%union { + int ival; + double dval; +} + +%token NUMBER +%type expr + +%% + +expr : '(' recur ')' + { foo( $$ = $2 ); } + ; + +recur : NUMBER + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax23.y b/contrib/byacc/test/err_syntax23.y new file mode 100644 index 000000000..4fe51c5c5 --- /dev/null +++ b/contrib/byacc/test/err_syntax23.y @@ -0,0 +1,46 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%union { + int ival; + double dval; +} + +%type recur + +%token NUMBER + +%% + +expr : '(' recur ')' + { $$ = $2; } + ; + +recur : NUMBER + { $$ = 1; } + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax24.y b/contrib/byacc/test/err_syntax24.y new file mode 100644 index 000000000..3cc4f87a7 --- /dev/null +++ b/contrib/byacc/test/err_syntax24.y @@ -0,0 +1,46 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%union { + int ival; + double dval; +} + +%start expr +%type expr + +%token NUMBER + +%% + +expr : '(' recur ')' + ; + +recur : NUMBER + { $$ = 1; } + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax25.y b/contrib/byacc/test/err_syntax25.y new file mode 100644 index 000000000..9b5dfd13e --- /dev/null +++ b/contrib/byacc/test/err_syntax25.y @@ -0,0 +1,51 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%union { + int ival; + double dval; +} + +%union { + int ival2; + double dval2; +} + +%start expr +%type expr + +%token NUMBER + +%% + +expr : '(' recur ')' + ; + +recur : NUMBER + { $$ = 1; } + ; + +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax26.y b/contrib/byacc/test/err_syntax26.y new file mode 100644 index 000000000..748382ba2 --- /dev/null +++ b/contrib/byacc/test/err_syntax26.y @@ -0,0 +1,6 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%type +# include + +#ifdef YYBISON +#define YYSTYPE int +#define YYLEX_PARAM base +#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM) +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +%} + +%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 */ + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main (void) +{ + int regs[26]; + int base = 10; + + while(!feof(stdin)) { + yyparse(regs, &base); + } + return 0; +} + +#define UNUSED(x) ((void)(x)) + +static void +YYERROR_DECL() +{ + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ + fprintf(stderr, "%s\n", s); +} + +int +YYLEX_DECL() +{ + /* 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') % (*base); + return ( DIGIT ); + } + return( c ); +} diff --git a/contrib/byacc/test/err_syntax3.y b/contrib/byacc/test/err_syntax3.y new file mode 100644 index 000000000..c10b227f2 --- /dev/null +++ b/contrib/byacc/test/err_syntax3.y @@ -0,0 +1,31 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token '(' '*' '& + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax4.y b/contrib/byacc/test/err_syntax4.y new file mode 100644 index 000000000..2c6f22ff2 --- /dev/null +++ b/contrib/byacc/test/err_syntax4.y @@ -0,0 +1,28 @@ +%{ +int yylex(void); +static void yyerror(const char *); +} +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax5.y b/contrib/byacc/test/err_syntax5.y new file mode 100644 index 000000000..ca9ce1a40 --- /dev/null +++ b/contrib/byacc/test/err_syntax5.y @@ -0,0 +1,33 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%union { + char *str; + int num + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax6.y b/contrib/byacc/test/err_syntax6.y new file mode 100644 index 000000000..5d87945cb --- /dev/null +++ b/contrib/byacc/test/err_syntax6.y @@ -0,0 +1,31 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax7.y b/contrib/byacc/test/err_syntax7.y new file mode 100644 index 000000000..783d563f3 --- /dev/null +++ b/contrib/byacc/test/err_syntax7.y @@ -0,0 +1,31 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token '\777' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax7a.y b/contrib/byacc/test/err_syntax7a.y new file mode 100644 index 000000000..ae105d0d0 --- /dev/null +++ b/contrib/byacc/test/err_syntax7a.y @@ -0,0 +1,31 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token '\xfff' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax7b.y b/contrib/byacc/test/err_syntax7b.y new file mode 100644 index 000000000..a3e5e216f --- /dev/null +++ b/contrib/byacc/test/err_syntax7b.y @@ -0,0 +1,31 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token '\x.' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax8.y b/contrib/byacc/test/err_syntax8.y new file mode 100644 index 000000000..5ac0974db --- /dev/null +++ b/contrib/byacc/test/err_syntax8.y @@ -0,0 +1,31 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token . '\777' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax8a.y b/contrib/byacc/test/err_syntax8a.y new file mode 100644 index 000000000..9a3a76cf4 --- /dev/null +++ b/contrib/byacc/test/err_syntax8a.y @@ -0,0 +1,31 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%token $$123 '\777' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/err_syntax9.y b/contrib/byacc/test/err_syntax9.y new file mode 100644 index 000000000..f3ec6fab3 --- /dev/null +++ b/contrib/byacc/test/err_syntax9.y @@ -0,0 +1,32 @@ +%{ +int yylex(void); +static void yyerror(const char *); +%} + +%start text +%token text '(' '*' '&' + +%% +S: error +%% + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} diff --git a/contrib/byacc/test/ftp.output b/contrib/byacc/test/ftp.output deleted file mode 100644 index c8931a5da..000000000 --- a/contrib/byacc/test/ftp.output +++ /dev/null @@ -1,1625 +0,0 @@ - 0 $accept : cmd_list $end - - 1 cmd_list : - 2 | cmd_list cmd - 3 | cmd_list rcmd - - 4 cmd : USER SP username CRLF - 5 | PASS SP password CRLF - 6 | PORT SP host_port CRLF - 7 | PASV CRLF - 8 | TYPE SP type_code CRLF - 9 | STRU SP struct_code CRLF - 10 | MODE SP mode_code CRLF - 11 | ALLO SP NUMBER CRLF - 12 | ALLO SP NUMBER SP R SP NUMBER CRLF - 13 | RETR check_login SP pathname CRLF - 14 | STOR check_login SP pathname CRLF - 15 | APPE check_login SP pathname CRLF - 16 | NLST check_login CRLF - 17 | NLST check_login SP STRING CRLF - 18 | LIST check_login CRLF - 19 | LIST check_login SP pathname CRLF - 20 | STAT check_login SP pathname CRLF - 21 | STAT CRLF - 22 | DELE check_login SP pathname CRLF - 23 | RNTO SP pathname CRLF - 24 | ABOR CRLF - 25 | CWD check_login CRLF - 26 | CWD check_login SP pathname CRLF - 27 | HELP CRLF - 28 | HELP SP STRING CRLF - 29 | NOOP CRLF - 30 | MKD check_login SP pathname CRLF - 31 | RMD check_login SP pathname CRLF - 32 | PWD check_login CRLF - 33 | CDUP check_login CRLF - 34 | SITE SP HELP CRLF - 35 | SITE SP HELP SP STRING CRLF - 36 | SITE SP UMASK check_login CRLF - 37 | SITE SP UMASK check_login SP octal_number CRLF - 38 | SITE SP CHMOD check_login SP octal_number SP pathname CRLF - 39 | SITE SP IDLE CRLF - 40 | SITE SP IDLE SP NUMBER CRLF - 41 | STOU check_login SP pathname CRLF - 42 | SYST CRLF - 43 | SIZE check_login SP pathname CRLF - 44 | MDTM check_login SP pathname CRLF - 45 | QUIT CRLF - 46 | error CRLF - - 47 rcmd : RNFR check_login SP pathname CRLF - - 48 username : STRING - - 49 password : - 50 | STRING - - 51 byte_size : NUMBER - - 52 host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER - - 53 form_code : N - 54 | T - 55 | C - - 56 type_code : A - 57 | A SP form_code - 58 | E - 59 | E SP form_code - 60 | I - 61 | L - 62 | L SP byte_size - 63 | L byte_size - - 64 struct_code : F - 65 | R - 66 | P - - 67 mode_code : S - 68 | B - 69 | C - - 70 pathname : pathstring - - 71 pathstring : STRING - - 72 octal_number : NUMBER - - 73 check_login : - -state 0 - $accept : . cmd_list $end (0) - cmd_list : . (1) - - . reduce 1 - - cmd_list goto 1 - - -state 1 - $accept : cmd_list . $end (0) - cmd_list : cmd_list . cmd (2) - cmd_list : cmd_list . rcmd (3) - - $end accept - error shift 2 - USER shift 3 - PASS shift 4 - QUIT shift 5 - PORT shift 6 - PASV shift 7 - TYPE shift 8 - STRU shift 9 - MODE shift 10 - RETR shift 11 - STOR shift 12 - APPE shift 13 - ALLO shift 14 - RNFR shift 15 - RNTO shift 16 - ABOR shift 17 - DELE shift 18 - CWD shift 19 - LIST shift 20 - NLST shift 21 - SITE shift 22 - STAT shift 23 - HELP shift 24 - NOOP shift 25 - MKD shift 26 - RMD shift 27 - PWD shift 28 - CDUP shift 29 - STOU shift 30 - SYST shift 31 - SIZE shift 32 - MDTM shift 33 - . error - - cmd goto 34 - rcmd goto 35 - - -state 2 - cmd : error . CRLF (46) - - CRLF shift 36 - . error - - -state 3 - cmd : USER . SP username CRLF (4) - - SP shift 37 - . error - - -state 4 - cmd : PASS . SP password CRLF (5) - - SP shift 38 - . error - - -state 5 - cmd : QUIT . CRLF (45) - - CRLF shift 39 - . error - - -state 6 - cmd : PORT . SP host_port CRLF (6) - - SP shift 40 - . error - - -state 7 - cmd : PASV . CRLF (7) - - CRLF shift 41 - . error - - -state 8 - cmd : TYPE . SP type_code CRLF (8) - - SP shift 42 - . error - - -state 9 - cmd : STRU . SP struct_code CRLF (9) - - SP shift 43 - . error - - -state 10 - cmd : MODE . SP mode_code CRLF (10) - - SP shift 44 - . error - - -state 11 - cmd : RETR . check_login SP pathname CRLF (13) - check_login : . (73) - - . reduce 73 - - check_login goto 45 - - -state 12 - cmd : STOR . check_login SP pathname CRLF (14) - check_login : . (73) - - . reduce 73 - - check_login goto 46 - - -state 13 - cmd : APPE . check_login SP pathname CRLF (15) - check_login : . (73) - - . reduce 73 - - check_login goto 47 - - -state 14 - cmd : ALLO . SP NUMBER CRLF (11) - cmd : ALLO . SP NUMBER SP R SP NUMBER CRLF (12) - - SP shift 48 - . error - - -state 15 - rcmd : RNFR . check_login SP pathname CRLF (47) - check_login : . (73) - - . reduce 73 - - check_login goto 49 - - -state 16 - cmd : RNTO . SP pathname CRLF (23) - - SP shift 50 - . error - - -state 17 - cmd : ABOR . CRLF (24) - - CRLF shift 51 - . error - - -state 18 - cmd : DELE . check_login SP pathname CRLF (22) - check_login : . (73) - - . reduce 73 - - check_login goto 52 - - -state 19 - cmd : CWD . check_login CRLF (25) - cmd : CWD . check_login SP pathname CRLF (26) - check_login : . (73) - - . reduce 73 - - check_login goto 53 - - -state 20 - cmd : LIST . check_login CRLF (18) - cmd : LIST . check_login SP pathname CRLF (19) - check_login : . (73) - - . reduce 73 - - check_login goto 54 - - -state 21 - cmd : NLST . check_login CRLF (16) - cmd : NLST . check_login SP STRING CRLF (17) - check_login : . (73) - - . reduce 73 - - check_login goto 55 - - -state 22 - cmd : SITE . SP HELP CRLF (34) - cmd : SITE . SP HELP SP STRING CRLF (35) - cmd : SITE . SP UMASK check_login CRLF (36) - cmd : SITE . SP UMASK check_login SP octal_number CRLF (37) - cmd : SITE . SP CHMOD check_login SP octal_number SP pathname CRLF (38) - cmd : SITE . SP IDLE CRLF (39) - cmd : SITE . SP IDLE SP NUMBER CRLF (40) - - SP shift 56 - . error - - -state 23 - cmd : STAT . check_login SP pathname CRLF (20) - cmd : STAT . CRLF (21) - check_login : . (73) - - CRLF shift 57 - SP reduce 73 - - check_login goto 58 - - -state 24 - cmd : HELP . CRLF (27) - cmd : HELP . SP STRING CRLF (28) - - SP shift 59 - CRLF shift 60 - . error - - -state 25 - cmd : NOOP . CRLF (29) - - CRLF shift 61 - . error - - -state 26 - cmd : MKD . check_login SP pathname CRLF (30) - check_login : . (73) - - . reduce 73 - - check_login goto 62 - - -state 27 - cmd : RMD . check_login SP pathname CRLF (31) - check_login : . (73) - - . reduce 73 - - check_login goto 63 - - -state 28 - cmd : PWD . check_login CRLF (32) - check_login : . (73) - - . reduce 73 - - check_login goto 64 - - -state 29 - cmd : CDUP . check_login CRLF (33) - check_login : . (73) - - . reduce 73 - - check_login goto 65 - - -state 30 - cmd : STOU . check_login SP pathname CRLF (41) - check_login : . (73) - - . reduce 73 - - check_login goto 66 - - -state 31 - cmd : SYST . CRLF (42) - - CRLF shift 67 - . error - - -state 32 - cmd : SIZE . check_login SP pathname CRLF (43) - check_login : . (73) - - . reduce 73 - - check_login goto 68 - - -state 33 - cmd : MDTM . check_login SP pathname CRLF (44) - check_login : . (73) - - . reduce 73 - - check_login goto 69 - - -state 34 - cmd_list : cmd_list cmd . (2) - - . reduce 2 - - -state 35 - cmd_list : cmd_list rcmd . (3) - - . reduce 3 - - -state 36 - cmd : error CRLF . (46) - - . reduce 46 - - -state 37 - cmd : USER SP . username CRLF (4) - - STRING shift 70 - . error - - username goto 71 - - -state 38 - cmd : PASS SP . password CRLF (5) - password : . (49) - - STRING shift 72 - CRLF reduce 49 - - password goto 73 - - -state 39 - cmd : QUIT CRLF . (45) - - . reduce 45 - - -state 40 - cmd : PORT SP . host_port CRLF (6) - - NUMBER shift 74 - . error - - host_port goto 75 - - -state 41 - cmd : PASV CRLF . (7) - - . reduce 7 - - -state 42 - cmd : TYPE SP . type_code CRLF (8) - - A shift 76 - E shift 77 - I shift 78 - L shift 79 - . error - - type_code goto 80 - - -state 43 - cmd : STRU SP . struct_code CRLF (9) - - F shift 81 - P shift 82 - R shift 83 - . error - - struct_code goto 84 - - -state 44 - cmd : MODE SP . mode_code CRLF (10) - - B shift 85 - C shift 86 - S shift 87 - . error - - mode_code goto 88 - - -state 45 - cmd : RETR check_login . SP pathname CRLF (13) - - SP shift 89 - . error - - -state 46 - cmd : STOR check_login . SP pathname CRLF (14) - - SP shift 90 - . error - - -state 47 - cmd : APPE check_login . SP pathname CRLF (15) - - SP shift 91 - . error - - -state 48 - cmd : ALLO SP . NUMBER CRLF (11) - cmd : ALLO SP . NUMBER SP R SP NUMBER CRLF (12) - - NUMBER shift 92 - . error - - -state 49 - rcmd : RNFR check_login . SP pathname CRLF (47) - - SP shift 93 - . error - - -state 50 - cmd : RNTO SP . pathname CRLF (23) - - STRING shift 94 - . error - - pathname goto 95 - pathstring goto 96 - - -state 51 - cmd : ABOR CRLF . (24) - - . reduce 24 - - -state 52 - cmd : DELE check_login . SP pathname CRLF (22) - - SP shift 97 - . error - - -state 53 - cmd : CWD check_login . CRLF (25) - cmd : CWD check_login . SP pathname CRLF (26) - - SP shift 98 - CRLF shift 99 - . error - - -state 54 - cmd : LIST check_login . CRLF (18) - cmd : LIST check_login . SP pathname CRLF (19) - - SP shift 100 - CRLF shift 101 - . error - - -state 55 - cmd : NLST check_login . CRLF (16) - cmd : NLST check_login . SP STRING CRLF (17) - - SP shift 102 - CRLF shift 103 - . error - - -state 56 - cmd : SITE SP . HELP CRLF (34) - cmd : SITE SP . HELP SP STRING CRLF (35) - cmd : SITE SP . UMASK check_login CRLF (36) - cmd : SITE SP . UMASK check_login SP octal_number CRLF (37) - cmd : SITE SP . CHMOD check_login SP octal_number SP pathname CRLF (38) - cmd : SITE SP . IDLE CRLF (39) - cmd : SITE SP . IDLE SP NUMBER CRLF (40) - - HELP shift 104 - UMASK shift 105 - IDLE shift 106 - CHMOD shift 107 - . error - - -state 57 - cmd : STAT CRLF . (21) - - . reduce 21 - - -state 58 - cmd : STAT check_login . SP pathname CRLF (20) - - SP shift 108 - . error - - -state 59 - cmd : HELP SP . STRING CRLF (28) - - STRING shift 109 - . error - - -state 60 - cmd : HELP CRLF . (27) - - . reduce 27 - - -state 61 - cmd : NOOP CRLF . (29) - - . reduce 29 - - -state 62 - cmd : MKD check_login . SP pathname CRLF (30) - - SP shift 110 - . error - - -state 63 - cmd : RMD check_login . SP pathname CRLF (31) - - SP shift 111 - . error - - -state 64 - cmd : PWD check_login . CRLF (32) - - CRLF shift 112 - . error - - -state 65 - cmd : CDUP check_login . CRLF (33) - - CRLF shift 113 - . error - - -state 66 - cmd : STOU check_login . SP pathname CRLF (41) - - SP shift 114 - . error - - -state 67 - cmd : SYST CRLF . (42) - - . reduce 42 - - -state 68 - cmd : SIZE check_login . SP pathname CRLF (43) - - SP shift 115 - . error - - -state 69 - cmd : MDTM check_login . SP pathname CRLF (44) - - SP shift 116 - . error - - -state 70 - username : STRING . (48) - - . reduce 48 - - -state 71 - cmd : USER SP username . CRLF (4) - - CRLF shift 117 - . error - - -state 72 - password : STRING . (50) - - . reduce 50 - - -state 73 - cmd : PASS SP password . CRLF (5) - - CRLF shift 118 - . error - - -state 74 - host_port : NUMBER . COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) - - COMMA shift 119 - . error - - -state 75 - cmd : PORT SP host_port . CRLF (6) - - CRLF shift 120 - . error - - -state 76 - type_code : A . (56) - type_code : A . SP form_code (57) - - SP shift 121 - CRLF reduce 56 - - -state 77 - type_code : E . (58) - type_code : E . SP form_code (59) - - SP shift 122 - CRLF reduce 58 - - -state 78 - type_code : I . (60) - - . reduce 60 - - -state 79 - type_code : L . (61) - type_code : L . SP byte_size (62) - type_code : L . byte_size (63) - - NUMBER shift 123 - SP shift 124 - CRLF reduce 61 - - byte_size goto 125 - - -state 80 - cmd : TYPE SP type_code . CRLF (8) - - CRLF shift 126 - . error - - -state 81 - struct_code : F . (64) - - . reduce 64 - - -state 82 - struct_code : P . (66) - - . reduce 66 - - -state 83 - struct_code : R . (65) - - . reduce 65 - - -state 84 - cmd : STRU SP struct_code . CRLF (9) - - CRLF shift 127 - . error - - -state 85 - mode_code : B . (68) - - . reduce 68 - - -state 86 - mode_code : C . (69) - - . reduce 69 - - -state 87 - mode_code : S . (67) - - . reduce 67 - - -state 88 - cmd : MODE SP mode_code . CRLF (10) - - CRLF shift 128 - . error - - -state 89 - cmd : RETR check_login SP . pathname CRLF (13) - - STRING shift 94 - . error - - pathname goto 129 - pathstring goto 96 - - -state 90 - cmd : STOR check_login SP . pathname CRLF (14) - - STRING shift 94 - . error - - pathname goto 130 - pathstring goto 96 - - -state 91 - cmd : APPE check_login SP . pathname CRLF (15) - - STRING shift 94 - . error - - pathname goto 131 - pathstring goto 96 - - -state 92 - cmd : ALLO SP NUMBER . CRLF (11) - cmd : ALLO SP NUMBER . SP R SP NUMBER CRLF (12) - - SP shift 132 - CRLF shift 133 - . error - - -state 93 - rcmd : RNFR check_login SP . pathname CRLF (47) - - STRING shift 94 - . error - - pathname goto 134 - pathstring goto 96 - - -state 94 - pathstring : STRING . (71) - - . reduce 71 - - -state 95 - cmd : RNTO SP pathname . CRLF (23) - - CRLF shift 135 - . error - - -state 96 - pathname : pathstring . (70) - - . reduce 70 - - -state 97 - cmd : DELE check_login SP . pathname CRLF (22) - - STRING shift 94 - . error - - pathname goto 136 - pathstring goto 96 - - -state 98 - cmd : CWD check_login SP . pathname CRLF (26) - - STRING shift 94 - . error - - pathname goto 137 - pathstring goto 96 - - -state 99 - cmd : CWD check_login CRLF . (25) - - . reduce 25 - - -state 100 - cmd : LIST check_login SP . pathname CRLF (19) - - STRING shift 94 - . error - - pathname goto 138 - pathstring goto 96 - - -state 101 - cmd : LIST check_login CRLF . (18) - - . reduce 18 - - -state 102 - cmd : NLST check_login SP . STRING CRLF (17) - - STRING shift 139 - . error - - -state 103 - cmd : NLST check_login CRLF . (16) - - . reduce 16 - - -state 104 - cmd : SITE SP HELP . CRLF (34) - cmd : SITE SP HELP . SP STRING CRLF (35) - - SP shift 140 - CRLF shift 141 - . error - - -state 105 - cmd : SITE SP UMASK . check_login CRLF (36) - cmd : SITE SP UMASK . check_login SP octal_number CRLF (37) - check_login : . (73) - - . reduce 73 - - check_login goto 142 - - -state 106 - cmd : SITE SP IDLE . CRLF (39) - cmd : SITE SP IDLE . SP NUMBER CRLF (40) - - SP shift 143 - CRLF shift 144 - . error - - -state 107 - cmd : SITE SP CHMOD . check_login SP octal_number SP pathname CRLF (38) - check_login : . (73) - - . reduce 73 - - check_login goto 145 - - -state 108 - cmd : STAT check_login SP . pathname CRLF (20) - - STRING shift 94 - . error - - pathname goto 146 - pathstring goto 96 - - -state 109 - cmd : HELP SP STRING . CRLF (28) - - CRLF shift 147 - . error - - -state 110 - cmd : MKD check_login SP . pathname CRLF (30) - - STRING shift 94 - . error - - pathname goto 148 - pathstring goto 96 - - -state 111 - cmd : RMD check_login SP . pathname CRLF (31) - - STRING shift 94 - . error - - pathname goto 149 - pathstring goto 96 - - -state 112 - cmd : PWD check_login CRLF . (32) - - . reduce 32 - - -state 113 - cmd : CDUP check_login CRLF . (33) - - . reduce 33 - - -state 114 - cmd : STOU check_login SP . pathname CRLF (41) - - STRING shift 94 - . error - - pathname goto 150 - pathstring goto 96 - - -state 115 - cmd : SIZE check_login SP . pathname CRLF (43) - - STRING shift 94 - . error - - pathname goto 151 - pathstring goto 96 - - -state 116 - cmd : MDTM check_login SP . pathname CRLF (44) - - STRING shift 94 - . error - - pathname goto 152 - pathstring goto 96 - - -state 117 - cmd : USER SP username CRLF . (4) - - . reduce 4 - - -state 118 - cmd : PASS SP password CRLF . (5) - - . reduce 5 - - -state 119 - host_port : NUMBER COMMA . NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) - - NUMBER shift 153 - . error - - -state 120 - cmd : PORT SP host_port CRLF . (6) - - . reduce 6 - - -state 121 - type_code : A SP . form_code (57) - - C shift 154 - N shift 155 - T shift 156 - . error - - form_code goto 157 - - -state 122 - type_code : E SP . form_code (59) - - C shift 154 - N shift 155 - T shift 156 - . error - - form_code goto 158 - - -state 123 - byte_size : NUMBER . (51) - - . reduce 51 - - -state 124 - type_code : L SP . byte_size (62) - - NUMBER shift 123 - . error - - byte_size goto 159 - - -state 125 - type_code : L byte_size . (63) - - . reduce 63 - - -state 126 - cmd : TYPE SP type_code CRLF . (8) - - . reduce 8 - - -state 127 - cmd : STRU SP struct_code CRLF . (9) - - . reduce 9 - - -state 128 - cmd : MODE SP mode_code CRLF . (10) - - . reduce 10 - - -state 129 - cmd : RETR check_login SP pathname . CRLF (13) - - CRLF shift 160 - . error - - -state 130 - cmd : STOR check_login SP pathname . CRLF (14) - - CRLF shift 161 - . error - - -state 131 - cmd : APPE check_login SP pathname . CRLF (15) - - CRLF shift 162 - . error - - -state 132 - cmd : ALLO SP NUMBER SP . R SP NUMBER CRLF (12) - - R shift 163 - . error - - -state 133 - cmd : ALLO SP NUMBER CRLF . (11) - - . reduce 11 - - -state 134 - rcmd : RNFR check_login SP pathname . CRLF (47) - - CRLF shift 164 - . error - - -state 135 - cmd : RNTO SP pathname CRLF . (23) - - . reduce 23 - - -state 136 - cmd : DELE check_login SP pathname . CRLF (22) - - CRLF shift 165 - . error - - -state 137 - cmd : CWD check_login SP pathname . CRLF (26) - - CRLF shift 166 - . error - - -state 138 - cmd : LIST check_login SP pathname . CRLF (19) - - CRLF shift 167 - . error - - -state 139 - cmd : NLST check_login SP STRING . CRLF (17) - - CRLF shift 168 - . error - - -state 140 - cmd : SITE SP HELP SP . STRING CRLF (35) - - STRING shift 169 - . error - - -state 141 - cmd : SITE SP HELP CRLF . (34) - - . reduce 34 - - -state 142 - cmd : SITE SP UMASK check_login . CRLF (36) - cmd : SITE SP UMASK check_login . SP octal_number CRLF (37) - - SP shift 170 - CRLF shift 171 - . error - - -state 143 - cmd : SITE SP IDLE SP . NUMBER CRLF (40) - - NUMBER shift 172 - . error - - -state 144 - cmd : SITE SP IDLE CRLF . (39) - - . reduce 39 - - -state 145 - cmd : SITE SP CHMOD check_login . SP octal_number SP pathname CRLF (38) - - SP shift 173 - . error - - -state 146 - cmd : STAT check_login SP pathname . CRLF (20) - - CRLF shift 174 - . error - - -state 147 - cmd : HELP SP STRING CRLF . (28) - - . reduce 28 - - -state 148 - cmd : MKD check_login SP pathname . CRLF (30) - - CRLF shift 175 - . error - - -state 149 - cmd : RMD check_login SP pathname . CRLF (31) - - CRLF shift 176 - . error - - -state 150 - cmd : STOU check_login SP pathname . CRLF (41) - - CRLF shift 177 - . error - - -state 151 - cmd : SIZE check_login SP pathname . CRLF (43) - - CRLF shift 178 - . error - - -state 152 - cmd : MDTM check_login SP pathname . CRLF (44) - - CRLF shift 179 - . error - - -state 153 - host_port : NUMBER COMMA NUMBER . COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) - - COMMA shift 180 - . error - - -state 154 - form_code : C . (55) - - . reduce 55 - - -state 155 - form_code : N . (53) - - . reduce 53 - - -state 156 - form_code : T . (54) - - . reduce 54 - - -state 157 - type_code : A SP form_code . (57) - - . reduce 57 - - -state 158 - type_code : E SP form_code . (59) - - . reduce 59 - - -state 159 - type_code : L SP byte_size . (62) - - . reduce 62 - - -state 160 - cmd : RETR check_login SP pathname CRLF . (13) - - . reduce 13 - - -state 161 - cmd : STOR check_login SP pathname CRLF . (14) - - . reduce 14 - - -state 162 - cmd : APPE check_login SP pathname CRLF . (15) - - . reduce 15 - - -state 163 - cmd : ALLO SP NUMBER SP R . SP NUMBER CRLF (12) - - SP shift 181 - . error - - -state 164 - rcmd : RNFR check_login SP pathname CRLF . (47) - - . reduce 47 - - -state 165 - cmd : DELE check_login SP pathname CRLF . (22) - - . reduce 22 - - -state 166 - cmd : CWD check_login SP pathname CRLF . (26) - - . reduce 26 - - -state 167 - cmd : LIST check_login SP pathname CRLF . (19) - - . reduce 19 - - -state 168 - cmd : NLST check_login SP STRING CRLF . (17) - - . reduce 17 - - -state 169 - cmd : SITE SP HELP SP STRING . CRLF (35) - - CRLF shift 182 - . error - - -state 170 - cmd : SITE SP UMASK check_login SP . octal_number CRLF (37) - - NUMBER shift 183 - . error - - octal_number goto 184 - - -state 171 - cmd : SITE SP UMASK check_login CRLF . (36) - - . reduce 36 - - -state 172 - cmd : SITE SP IDLE SP NUMBER . CRLF (40) - - CRLF shift 185 - . error - - -state 173 - cmd : SITE SP CHMOD check_login SP . octal_number SP pathname CRLF (38) - - NUMBER shift 183 - . error - - octal_number goto 186 - - -state 174 - cmd : STAT check_login SP pathname CRLF . (20) - - . reduce 20 - - -state 175 - cmd : MKD check_login SP pathname CRLF . (30) - - . reduce 30 - - -state 176 - cmd : RMD check_login SP pathname CRLF . (31) - - . reduce 31 - - -state 177 - cmd : STOU check_login SP pathname CRLF . (41) - - . reduce 41 - - -state 178 - cmd : SIZE check_login SP pathname CRLF . (43) - - . reduce 43 - - -state 179 - cmd : MDTM check_login SP pathname CRLF . (44) - - . reduce 44 - - -state 180 - host_port : NUMBER COMMA NUMBER COMMA . NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) - - NUMBER shift 187 - . error - - -state 181 - cmd : ALLO SP NUMBER SP R SP . NUMBER CRLF (12) - - NUMBER shift 188 - . error - - -state 182 - cmd : SITE SP HELP SP STRING CRLF . (35) - - . reduce 35 - - -state 183 - octal_number : NUMBER . (72) - - . reduce 72 - - -state 184 - cmd : SITE SP UMASK check_login SP octal_number . CRLF (37) - - CRLF shift 189 - . error - - -state 185 - cmd : SITE SP IDLE SP NUMBER CRLF . (40) - - . reduce 40 - - -state 186 - cmd : SITE SP CHMOD check_login SP octal_number . SP pathname CRLF (38) - - SP shift 190 - . error - - -state 187 - host_port : NUMBER COMMA NUMBER COMMA NUMBER . COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) - - COMMA shift 191 - . error - - -state 188 - cmd : ALLO SP NUMBER SP R SP NUMBER . CRLF (12) - - CRLF shift 192 - . error - - -state 189 - cmd : SITE SP UMASK check_login SP octal_number CRLF . (37) - - . reduce 37 - - -state 190 - cmd : SITE SP CHMOD check_login SP octal_number SP . pathname CRLF (38) - - STRING shift 94 - . error - - pathname goto 193 - pathstring goto 96 - - -state 191 - host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA . NUMBER COMMA NUMBER COMMA NUMBER (52) - - NUMBER shift 194 - . error - - -state 192 - cmd : ALLO SP NUMBER SP R SP NUMBER CRLF . (12) - - . reduce 12 - - -state 193 - cmd : SITE SP CHMOD check_login SP octal_number SP pathname . CRLF (38) - - CRLF shift 195 - . error - - -state 194 - host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER . COMMA NUMBER COMMA NUMBER (52) - - COMMA shift 196 - . error - - -state 195 - cmd : SITE SP CHMOD check_login SP octal_number SP pathname CRLF . (38) - - . reduce 38 - - -state 196 - host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA . NUMBER COMMA NUMBER (52) - - NUMBER shift 197 - . error - - -state 197 - host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER . COMMA NUMBER (52) - - COMMA shift 198 - . error - - -state 198 - host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA . NUMBER (52) - - NUMBER shift 199 - . error - - -state 199 - host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER . (52) - - . reduce 52 - - -65 terminals, 16 nonterminals -74 grammar rules, 200 states diff --git a/contrib/byacc/test/ftp.tab.c b/contrib/byacc/test/ftp.tab.c deleted file mode 100644 index 6f32cb4ef..000000000 --- a/contrib/byacc/test/ftp.tab.c +++ /dev/null @@ -1,2010 +0,0 @@ -#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 ftp_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex ftp_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror ftp_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar ftp_char -#endif /* yychar */ - -#ifndef yyval -#define yyval ftp_val -#endif /* yyval */ - -#ifndef yylval -#define yylval ftp_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug ftp_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs ftp_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag ftp_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs ftp_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen ftp_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred ftp_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto ftp_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex ftp_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex ftp_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex ftp_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable ftp_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck ftp_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname ftp_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule ftp_rule -#endif /* yyrule */ -#define YYPREFIX "ftp_" - -#define YYPURE 0 - -#line 26 "ftp.y" - -/* sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89"; */ - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *); -#endif - -extern struct sockaddr_in data_dest; -extern int logged_in; -extern struct passwd *pw; -extern int guest; -extern int logging; -extern int type; -extern int form; -extern int debug; -extern int timeout; -extern int maxtimeout; -extern int pdata; -extern char hostname[], remotehost[]; -extern char proctitle[]; -extern char *globerr; -extern int usedefault; -extern int transflag; -extern char tmpline[]; - -extern char **glob(char *); -extern char *renamefrom(char *); -extern void cwd(const char *); - -extern void dologout(int); -extern void fatal(const char *); -extern void makedir(const char *); -extern void nack(const char *); -extern void pass(const char *); -extern void passive(void); -extern void pwd(void); -extern void removedir(char *); -extern void renamecmd(char *, char *); -extern void retrieve(const char *, const char *); -extern void send_file_list(const char *); -extern void statcmd(void); -extern void statfilecmd(const char *); -extern void store(char *, const char *, int); -extern void user(const char *); - -extern void perror_reply(int, const char *, ...); -extern void reply(int, const char *, ...); -extern void lreply(int, const char *, ...); - -static int cmd_type; -static int cmd_form; -static int cmd_bytesz; -char cbuf[512]; -char *fromname; - -struct tab { - const char *name; - short token; - short state; - short implemented; /* 1 if command is implemented */ - const char *help; -}; - -static char * copy(const char *); - -#ifdef YYBISON -static void sizecmd(char *filename); -static void help(struct tab *ctab, char *s); -struct tab cmdtab[]; -struct tab sitetab[]; -#endif - -static void -yyerror(const char *msg) -{ - perror(msg); -} -#line 126 "ftp.y" -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -typedef union -{ - int ival; - char *sval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 211 "ftp.tab.c" - -/* 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 NUMBER 257 -#define STRING 258 -#define A 259 -#define B 260 -#define C 261 -#define E 262 -#define F 263 -#define I 264 -#define L 265 -#define N 266 -#define P 267 -#define R 268 -#define S 269 -#define T 270 -#define SP 271 -#define CRLF 272 -#define COMMA 273 -#define USER 274 -#define PASS 275 -#define ACCT 276 -#define REIN 277 -#define QUIT 278 -#define PORT 279 -#define PASV 280 -#define TYPE 281 -#define STRU 282 -#define MODE 283 -#define RETR 284 -#define STOR 285 -#define APPE 286 -#define MLFL 287 -#define MAIL 288 -#define MSND 289 -#define MSOM 290 -#define MSAM 291 -#define MRSQ 292 -#define MRCP 293 -#define ALLO 294 -#define REST 295 -#define RNFR 296 -#define RNTO 297 -#define ABOR 298 -#define DELE 299 -#define CWD 300 -#define LIST 301 -#define NLST 302 -#define SITE 303 -#define STAT 304 -#define HELP 305 -#define NOOP 306 -#define MKD 307 -#define RMD 308 -#define PWD 309 -#define CDUP 310 -#define STOU 311 -#define SMNT 312 -#define SYST 313 -#define SIZE 314 -#define MDTM 315 -#define UMASK 316 -#define IDLE 317 -#define CHMOD 318 -#define LEXERR 319 -#define YYERRCODE 256 -static const short ftp_lhs[] = { -1, - 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 12, 10, 7, 7, - 1, 13, 3, 3, 3, 14, 14, 14, 14, 14, - 14, 14, 14, 6, 6, 6, 4, 4, 4, 8, - 9, 5, 2, -}; -static const short ftp_len[] = { 2, - 0, 2, 2, 4, 4, 4, 2, 4, 4, 4, - 4, 8, 5, 5, 5, 3, 5, 3, 5, 5, - 2, 5, 4, 2, 3, 5, 2, 4, 2, 5, - 5, 3, 3, 4, 6, 5, 7, 9, 4, 6, - 5, 2, 5, 5, 2, 2, 5, 1, 0, 1, - 1, 11, 1, 1, 1, 1, 3, 1, 3, 1, - 1, 3, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, -}; -static const short ftp_defred[] = { 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 73, 73, 73, 0, 73, 0, 0, 73, 73, 73, - 73, 0, 0, 0, 0, 73, 73, 73, 73, 73, - 0, 73, 73, 2, 3, 46, 0, 0, 45, 0, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 24, 0, 0, 0, 0, 0, 21, 0, 0, 27, - 29, 0, 0, 0, 0, 0, 42, 0, 0, 48, - 0, 50, 0, 0, 0, 0, 0, 60, 0, 0, - 64, 66, 65, 0, 68, 69, 67, 0, 0, 0, - 0, 0, 0, 71, 0, 70, 0, 0, 25, 0, - 18, 0, 16, 0, 73, 0, 73, 0, 0, 0, - 0, 32, 33, 0, 0, 0, 4, 5, 0, 6, - 0, 0, 51, 0, 63, 8, 9, 10, 0, 0, - 0, 0, 11, 0, 23, 0, 0, 0, 0, 0, - 34, 0, 0, 39, 0, 0, 28, 0, 0, 0, - 0, 0, 0, 55, 53, 54, 57, 59, 62, 13, - 14, 15, 0, 47, 22, 26, 19, 17, 0, 0, - 36, 0, 0, 20, 30, 31, 41, 43, 44, 0, - 0, 35, 72, 0, 40, 0, 0, 0, 37, 0, - 0, 12, 0, 0, 38, 0, 0, 0, 52, -}; -static const short ftp_dgoto[] = { 1, - 125, 45, 157, 88, 184, 84, 73, 95, 96, 71, - 34, 35, 75, 80, -}; -static const short ftp_sindex[] = { 0, - -224, -256, -248, -241, -239, -233, -225, -218, -200, -165, - 0, 0, 0, -164, 0, -163, -176, 0, 0, 0, - 0, -162, -161, -231, -160, 0, 0, 0, 0, 0, - -159, 0, 0, 0, 0, 0, -240, -148, 0, -143, - 0, -252, -175, -255, -156, -155, -154, -139, -152, -138, - 0, -149, -205, -203, -177, -253, 0, -147, -133, 0, - 0, -145, -144, -142, -141, -137, 0, -136, -135, 0, - -140, 0, -134, -132, -130, -131, -128, 0, -254, -127, - 0, 0, 0, -126, 0, 0, 0, -125, -138, -138, - -138, -174, -138, 0, -124, 0, -138, -138, 0, -138, - 0, -129, 0, -172, 0, -169, 0, -138, -123, -138, - -138, 0, 0, -138, -138, -138, 0, 0, -120, 0, - -246, -246, 0, -118, 0, 0, 0, 0, -122, -121, - -119, -116, 0, -117, 0, -115, -114, -113, -112, -104, - 0, -167, -101, 0, -110, -109, 0, -108, -107, -106, - -105, -103, -111, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -100, 0, 0, 0, 0, 0, -102, -85, - 0, -99, -85, 0, 0, 0, 0, 0, 0, -83, - -82, 0, 0, -96, 0, -94, -95, -93, 0, -138, - -77, 0, -91, -90, 0, -75, -88, -73, 0, -}; -static const short ftp_rindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -84, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -86, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -81, -80, 0, -160, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; -static const short ftp_gindex[] = { 0, - 4, 16, 11, 0, -29, 0, 0, -89, 0, 0, - 0, 0, 0, 0, -}; -#define YYTABLESIZE 192 -static const short ftp_table[] = { 129, - 130, 131, 123, 134, 85, 86, 76, 136, 137, 77, - 138, 78, 79, 87, 154, 36, 124, 70, 146, 155, - 148, 149, 37, 156, 150, 151, 152, 46, 47, 38, - 49, 2, 39, 52, 53, 54, 55, 40, 58, 59, - 60, 62, 63, 64, 65, 66, 41, 68, 69, 3, - 4, 104, 42, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 105, 106, 107, 98, 99, 100, 101, 14, - 43, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 81, 31, 32, - 33, 82, 83, 102, 103, 51, 132, 133, 140, 141, - 193, 143, 144, 170, 171, 44, 48, 50, 56, 72, - 57, 61, 67, 74, 89, 90, 91, 92, 93, 94, - 142, 97, 145, 108, 109, 110, 111, 159, 139, 112, - 113, 117, 158, 114, 115, 116, 153, 118, 123, 121, - 119, 120, 122, 186, 126, 127, 128, 135, 147, 160, - 161, 163, 162, 169, 164, 172, 165, 166, 167, 168, - 173, 180, 174, 175, 176, 177, 178, 0, 179, 182, - 181, 183, 185, 187, 188, 189, 190, 191, 192, 194, - 195, 197, 196, 199, 198, 49, 73, 0, 0, 0, - 56, 58, -}; -static const short ftp_check[] = { 89, - 90, 91, 257, 93, 260, 261, 259, 97, 98, 262, - 100, 264, 265, 269, 261, 272, 271, 258, 108, 266, - 110, 111, 271, 270, 114, 115, 116, 12, 13, 271, - 15, 256, 272, 18, 19, 20, 21, 271, 23, 271, - 272, 26, 27, 28, 29, 30, 272, 32, 33, 274, - 275, 305, 271, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 316, 317, 318, 271, 272, 271, 272, 294, - 271, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 263, 313, 314, - 315, 267, 268, 271, 272, 272, 271, 272, 271, 272, - 190, 271, 272, 271, 272, 271, 271, 271, 271, 258, - 272, 272, 272, 257, 271, 271, 271, 257, 271, 258, - 105, 271, 107, 271, 258, 271, 271, 124, 258, 272, - 272, 272, 122, 271, 271, 271, 257, 272, 257, 271, - 273, 272, 271, 173, 272, 272, 272, 272, 272, 272, - 272, 268, 272, 258, 272, 257, 272, 272, 272, 272, - 271, 273, 272, 272, 272, 272, 272, -1, 272, 272, - 271, 257, 272, 257, 257, 272, 271, 273, 272, 257, - 272, 257, 273, 257, 273, 272, 271, -1, -1, -1, - 272, 272, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 319 -#if YYDEBUG -static const char *yyname[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","STRING","A","B","C","E", -"F","I","L","N","P","R","S","T","SP","CRLF","COMMA","USER","PASS","ACCT","REIN", -"QUIT","PORT","PASV","TYPE","STRU","MODE","RETR","STOR","APPE","MLFL","MAIL", -"MSND","MSOM","MSAM","MRSQ","MRCP","ALLO","REST","RNFR","RNTO","ABOR","DELE", -"CWD","LIST","NLST","SITE","STAT","HELP","NOOP","MKD","RMD","PWD","CDUP","STOU", -"SMNT","SYST","SIZE","MDTM","UMASK","IDLE","CHMOD","LEXERR", -}; -static const char *yyrule[] = { -"$accept : cmd_list", -"cmd_list :", -"cmd_list : cmd_list cmd", -"cmd_list : cmd_list rcmd", -"cmd : USER SP username CRLF", -"cmd : PASS SP password CRLF", -"cmd : PORT SP host_port CRLF", -"cmd : PASV CRLF", -"cmd : TYPE SP type_code CRLF", -"cmd : STRU SP struct_code CRLF", -"cmd : MODE SP mode_code CRLF", -"cmd : ALLO SP NUMBER CRLF", -"cmd : ALLO SP NUMBER SP R SP NUMBER CRLF", -"cmd : RETR check_login SP pathname CRLF", -"cmd : STOR check_login SP pathname CRLF", -"cmd : APPE check_login SP pathname CRLF", -"cmd : NLST check_login CRLF", -"cmd : NLST check_login SP STRING CRLF", -"cmd : LIST check_login CRLF", -"cmd : LIST check_login SP pathname CRLF", -"cmd : STAT check_login SP pathname CRLF", -"cmd : STAT CRLF", -"cmd : DELE check_login SP pathname CRLF", -"cmd : RNTO SP pathname CRLF", -"cmd : ABOR CRLF", -"cmd : CWD check_login CRLF", -"cmd : CWD check_login SP pathname CRLF", -"cmd : HELP CRLF", -"cmd : HELP SP STRING CRLF", -"cmd : NOOP CRLF", -"cmd : MKD check_login SP pathname CRLF", -"cmd : RMD check_login SP pathname CRLF", -"cmd : PWD check_login CRLF", -"cmd : CDUP check_login CRLF", -"cmd : SITE SP HELP CRLF", -"cmd : SITE SP HELP SP STRING CRLF", -"cmd : SITE SP UMASK check_login CRLF", -"cmd : SITE SP UMASK check_login SP octal_number CRLF", -"cmd : SITE SP CHMOD check_login SP octal_number SP pathname CRLF", -"cmd : SITE SP IDLE CRLF", -"cmd : SITE SP IDLE SP NUMBER CRLF", -"cmd : STOU check_login SP pathname CRLF", -"cmd : SYST CRLF", -"cmd : SIZE check_login SP pathname CRLF", -"cmd : MDTM check_login SP pathname CRLF", -"cmd : QUIT CRLF", -"cmd : error CRLF", -"rcmd : RNFR check_login SP pathname CRLF", -"username : STRING", -"password :", -"password : STRING", -"byte_size : NUMBER", -"host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER", -"form_code : N", -"form_code : T", -"form_code : C", -"type_code : A", -"type_code : A SP form_code", -"type_code : E", -"type_code : E SP form_code", -"type_code : I", -"type_code : L", -"type_code : L SP byte_size", -"type_code : L byte_size", -"struct_code : F", -"struct_code : R", -"struct_code : P", -"mode_code : S", -"mode_code : B", -"mode_code : C", -"pathname : pathstring", -"pathstring : STRING", -"octal_number : NUMBER", -"check_login :", - -}; -#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 500 -#define YYMAXDEPTH 500 -#endif -#endif - -#define YYINITSTACKSIZE 500 - -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 733 "ftp.y" - -#ifdef YYBYACC -extern int YYLEX_DECL(); -#endif - -extern jmp_buf errcatch; - -static void upper(char *); - -#define CMD 0 /* beginning of command */ -#define ARGS 1 /* expect miscellaneous arguments */ -#define STR1 2 /* expect SP followed by STRING */ -#define STR2 3 /* expect STRING */ -#define OSTR 4 /* optional SP then STRING */ -#define ZSTR1 5 /* SP then optional STRING */ -#define ZSTR2 6 /* optional STRING after SP */ -#define SITECMD 7 /* SITE command */ -#define NSTR 8 /* Number followed by a string */ - -struct tab cmdtab[] = { /* In order defined in RFC 765 */ - { "USER", USER, STR1, 1, " username" }, - { "PASS", PASS, ZSTR1, 1, " password" }, - { "ACCT", ACCT, STR1, 0, "(specify account)" }, - { "SMNT", SMNT, ARGS, 0, "(structure mount)" }, - { "REIN", REIN, ARGS, 0, "(reinitialize server state)" }, - { "QUIT", QUIT, ARGS, 1, "(terminate service)", }, - { "PORT", PORT, ARGS, 1, " b0, b1, b2, b3, b4" }, - { "PASV", PASV, ARGS, 1, "(set server in passive mode)" }, - { "TYPE", TYPE, ARGS, 1, " [ A | E | I | L ]" }, - { "STRU", STRU, ARGS, 1, "(specify file structure)" }, - { "MODE", MODE, ARGS, 1, "(specify transfer mode)" }, - { "RETR", RETR, STR1, 1, " file-name" }, - { "STOR", STOR, STR1, 1, " file-name" }, - { "APPE", APPE, STR1, 1, " file-name" }, - { "MLFL", MLFL, OSTR, 0, "(mail file)" }, - { "MAIL", MAIL, OSTR, 0, "(mail to user)" }, - { "MSND", MSND, OSTR, 0, "(mail send to terminal)" }, - { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" }, - { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" }, - { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" }, - { "MRCP", MRCP, STR1, 0, "(mail recipient)" }, - { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" }, - { "REST", REST, ARGS, 0, "(restart command)" }, - { "RNFR", RNFR, STR1, 1, " file-name" }, - { "RNTO", RNTO, STR1, 1, " file-name" }, - { "ABOR", ABOR, ARGS, 1, "(abort operation)" }, - { "DELE", DELE, STR1, 1, " file-name" }, - { "CWD", CWD, OSTR, 1, "[ directory-name ]" }, - { "XCWD", CWD, OSTR, 1, "[ directory-name ]" }, - { "LIST", LIST, OSTR, 1, "[ path-name ]" }, - { "NLST", NLST, OSTR, 1, "[ path-name ]" }, - { "SITE", SITE, SITECMD, 1, "site-cmd [ arguments ]" }, - { "SYST", SYST, ARGS, 1, "(get type of operating system)" }, - { "STAT", STAT, OSTR, 1, "[ path-name ]" }, - { "HELP", HELP, OSTR, 1, "[ ]" }, - { "NOOP", NOOP, ARGS, 1, "" }, - { "MKD", MKD, STR1, 1, " path-name" }, - { "XMKD", MKD, STR1, 1, " path-name" }, - { "RMD", RMD, STR1, 1, " path-name" }, - { "XRMD", RMD, STR1, 1, " path-name" }, - { "PWD", PWD, ARGS, 1, "(return current directory)" }, - { "XPWD", PWD, ARGS, 1, "(return current directory)" }, - { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" }, - { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" }, - { "STOU", STOU, STR1, 1, " file-name" }, - { "SIZE", SIZE, OSTR, 1, " path-name" }, - { "MDTM", MDTM, OSTR, 1, " path-name" }, - { 0, 0, 0, 0, 0 } -}; - -struct tab sitetab[] = { - { "UMASK", UMASK, ARGS, 1, "[ umask ]" }, - { "IDLE", IDLE, ARGS, 1, "[ maximum-idle-time ]" }, - { "CHMOD", CHMOD, NSTR, 1, " mode file-name" }, - { "HELP", HELP, OSTR, 1, "[ ]" }, - { 0, 0, 0, 0, 0 } -}; - -static struct tab * -lookup(struct tab *p, char *cmd) -{ - - for (; p->name != 0; p++) - if (strcmp(cmd, p->name) == 0) - return (p); - return (0); -} - -#include - -/* - * get_line - a hacked up version of fgets to ignore TELNET escape codes. - */ -static char * -get_line(char *s, int n, FILE *iop) -{ - register int c; - register char *cs; - - cs = s; -/* tmpline may contain saved command from urgent mode interruption */ - for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) { - *cs++ = tmpline[c]; - if (tmpline[c] == '\n') { - *cs = '\0'; - if (debug) - syslog(LOG_DEBUG, "command: %s", s); - tmpline[0] = '\0'; - return(s); - } - if (c == 0) - tmpline[0] = '\0'; - } - while ((c = getc(iop)) != EOF) { - c &= 0377; - if (c == IAC) { - if ((c = getc(iop)) != EOF) { - c &= 0377; - switch (c) { - case WILL: - case WONT: - c = getc(iop); - printf("%c%c%c", IAC, DONT, 0377&c); - (void) fflush(stdout); - continue; - case DO: - case DONT: - c = getc(iop); - printf("%c%c%c", IAC, WONT, 0377&c); - (void) fflush(stdout); - continue; - case IAC: - break; - default: - continue; /* ignore command */ - } - } - } - *cs++ = (char) c; - if (--n <= 0 || c == '\n') - break; - } - if (c == EOF && cs == s) - return (0); - *cs = '\0'; - if (debug) - syslog(LOG_DEBUG, "command: %s", s); - return (s); -} - -static void -toolong(int sig) -{ - time_t now; - - (void) sig; - reply(421, - "Timeout (%d seconds): closing control connection.", timeout); - (void) time(&now); - if (logging) { - syslog(LOG_INFO, - "User %s timed out after %d seconds at %s", - (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now)); - } - dologout(1); -} - -int -yylex(void) -{ - static int cpos, state; - register char *cp, *cp2; - register struct tab *p; - int n; - char c; - - for (;;) { - switch (state) { - - case CMD: - (void) signal(SIGALRM, toolong); - (void) alarm((unsigned) timeout); - if (get_line(cbuf, sizeof(cbuf)-1, stdin) == 0) { - reply(221, "You could at least say goodbye."); - dologout(0); - } - (void) alarm(0); -#ifdef SETPROCTITLE - if (strncasecmp(cbuf, "PASS", 4) != 0) - setproctitle("%s: %s", proctitle, cbuf); -#endif /* SETPROCTITLE */ - if ((cp = strchr(cbuf, '\r'))) { - *cp++ = '\n'; - *cp = '\0'; - } - if ((cp = strpbrk(cbuf, " \n"))) - cpos = (int) (cp - cbuf); - if (cpos == 0) - cpos = 4; - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - upper(cbuf); - p = lookup(cmdtab, cbuf); - cbuf[cpos] = c; - if (p != 0) { - if (p->implemented == 0) { - nack(p->name); - longjmp(errcatch,0); - /* NOTREACHED */ - } - state = p->state; - *(const char **)(&yylval) = p->name; - return (p->token); - } - break; - - case SITECMD: - if (cbuf[cpos] == ' ') { - cpos++; - return (SP); - } - cp = &cbuf[cpos]; - if ((cp2 = strpbrk(cp, " \n"))) - cpos = (int) (cp2 - cbuf); - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - upper(cp); - p = lookup(sitetab, cp); - cbuf[cpos] = c; - if (p != 0) { - if (p->implemented == 0) { - state = CMD; - nack(p->name); - longjmp(errcatch,0); - /* NOTREACHED */ - } - state = p->state; - *(const char **)(&yylval) = p->name; - return (p->token); - } - state = CMD; - break; - - case OSTR: - if (cbuf[cpos] == '\n') { - state = CMD; - return (CRLF); - } - /* FALLTHROUGH */ - - case STR1: - case ZSTR1: - dostr1: - if (cbuf[cpos] == ' ') { - cpos++; - if (state == OSTR) - state = STR2; - else - ++state; - return (SP); - } - break; - - case ZSTR2: - if (cbuf[cpos] == '\n') { - state = CMD; - return (CRLF); - } - /* FALLTHROUGH */ - - case STR2: - cp = &cbuf[cpos]; - n = (int) strlen(cp); - cpos += n - 1; - /* - * Make sure the string is nonempty and \n terminated. - */ - if (n > 1 && cbuf[cpos] == '\n') { - cbuf[cpos] = '\0'; - *(char **)&yylval = copy(cp); - cbuf[cpos] = '\n'; - state = ARGS; - return (STRING); - } - break; - - case NSTR: - if (cbuf[cpos] == ' ') { - cpos++; - return (SP); - } - if (isdigit(cbuf[cpos])) { - cp = &cbuf[cpos]; - while (isdigit(cbuf[++cpos])) - ; - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - yylval.ival = atoi(cp); - cbuf[cpos] = c; - state = STR1; - return (NUMBER); - } - state = STR1; - goto dostr1; - - case ARGS: - if (isdigit(cbuf[cpos])) { - cp = &cbuf[cpos]; - while (isdigit(cbuf[++cpos])) - ; - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - yylval.ival = atoi(cp); - cbuf[cpos] = c; - return (NUMBER); - } - switch (cbuf[cpos++]) { - - case '\n': - state = CMD; - return (CRLF); - - case ' ': - return (SP); - - case ',': - return (COMMA); - - case 'A': - case 'a': - return (A); - - case 'B': - case 'b': - return (B); - - case 'C': - case 'c': - return (C); - - case 'E': - case 'e': - return (E); - - case 'F': - case 'f': - return (F); - - case 'I': - case 'i': - return (I); - - case 'L': - case 'l': - return (L); - - case 'N': - case 'n': - return (N); - - case 'P': - case 'p': - return (P); - - case 'R': - case 'r': - return (R); - - case 'S': - case 's': - return (S); - - case 'T': - case 't': - return (T); - - } - break; - - default: - fatal("Unknown state in scanner."); - } - yyerror((char *) 0); - state = CMD; - longjmp(errcatch,0); - } -} - -static void -upper(char *s) -{ - while (*s != '\0') { - if (islower(*s)) - *s = toupper(*s); - s++; - } -} - -static char * -copy(const char *s) -{ - char *p; - - p = (char * )malloc(strlen(s) + 1); - if (p == 0) - fatal("Ran out of memory."); - else - (void) strcpy(p, s); - return (p); -} - -static void -help(struct tab *ctab, char *s) -{ - register struct tab *c; - register int width, NCMDS; - const char *help_type; - - if (ctab == sitetab) - help_type = "SITE "; - else - help_type = ""; - width = 0, NCMDS = 0; - for (c = ctab; c->name != 0; c++) { - int len = (int) strlen(c->name); - - if (len > width) - width = len; - NCMDS++; - } - width = (width + 8) &~ 7; - if (s == 0) { - register int i, j, w; - int columns, lines; - - lreply(214, "The following %scommands are recognized %s.", - help_type, "(* =>'s unimplemented)"); - columns = 76 / width; - if (columns == 0) - columns = 1; - lines = (NCMDS + columns - 1) / columns; - for (i = 0; i < lines; i++) { - printf(" "); - for (j = 0; j < columns; j++) { - c = ctab + j * lines + i; - assert(c->name != 0); - printf("%s%c", c->name, - c->implemented ? ' ' : '*'); - if (c + lines >= &ctab[NCMDS]) - break; - w = (int) strlen(c->name) + 1; - while (w < width) { - putchar(' '); - w++; - } - } - printf("\r\n"); - } - (void) fflush(stdout); - reply(214, "Direct comments to ftp-bugs@%s.", hostname); - return; - } - upper(s); - c = lookup(ctab, s); - if (c == (struct tab *)0) { - reply(502, "Unknown command %s.", s); - return; - } - if (c->implemented) - reply(214, "Syntax: %s%s %s", help_type, c->name, c->help); - else - reply(214, "%s%-*s\t%s; unimplemented.", help_type, width, - c->name, c->help); -} - -static void -sizecmd(char *filename) -{ - switch (type) { - case TYPE_L: - case TYPE_I: { - struct stat stbuf; - if (stat(filename, &stbuf) < 0 || - (stbuf.st_mode&S_IFMT) != S_IFREG) - reply(550, "%s: not a plain file.", filename); - else -#ifdef HAVE_LONG_LONG - reply(213, "%llu", (long long) stbuf.st_size); -#else - reply(213, "%lu", stbuf.st_size); -#endif - break;} - case TYPE_A: { - FILE *fin; - register int c, count; - struct stat stbuf; - fin = fopen(filename, "r"); - if (fin == 0) { - perror_reply(550, filename); - return; - } - if (fstat(fileno(fin), &stbuf) < 0 || - (stbuf.st_mode&S_IFMT) != S_IFREG) { - reply(550, "%s: not a plain file.", filename); - (void) fclose(fin); - return; - } - - count = 0; - while((c=getc(fin)) != EOF) { - if (c == '\n') /* will get expanded to \r\n */ - count++; - count++; - } - (void) fclose(fin); - - reply(213, "%ld", count); - break;} - default: - reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]); - } -} -#line 1103 "ftp.tab.c" - -#if YYDEBUG -#include /* needed for printf */ -#endif - -#include /* needed for malloc, etc */ -#include /* 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 = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - 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 = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - 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 2: -#line 172 "ftp.y" - { - fromname = (char *) 0; - } -break; -case 4: -#line 179 "ftp.y" - { - user(yystack.l_mark[-1].sval); - free(yystack.l_mark[-1].sval); - } -break; -case 5: -#line 184 "ftp.y" - { - pass(yystack.l_mark[-1].sval); - free(yystack.l_mark[-1].sval); - } -break; -case 6: -#line 189 "ftp.y" - { - usedefault = 0; - if (pdata >= 0) { - (void) close(pdata); - pdata = -1; - } - reply(200, "PORT command successful."); - } -break; -case 7: -#line 198 "ftp.y" - { - passive(); - } -break; -case 8: -#line 202 "ftp.y" - { - switch (cmd_type) { - - case TYPE_A: - if (cmd_form == FORM_N) { - reply(200, "Type set to A."); - type = cmd_type; - form = cmd_form; - } else - reply(504, "Form must be N."); - break; - - case TYPE_E: - reply(504, "Type E not implemented."); - break; - - case TYPE_I: - reply(200, "Type set to I."); - type = cmd_type; - break; - - case TYPE_L: -#if NBBY == 8 - if (cmd_bytesz == 8) { - reply(200, - "Type set to L (byte size 8)."); - type = cmd_type; - } else - reply(504, "Byte size must be 8."); -#else /* NBBY == 8 */ - UNIMPLEMENTED for NBBY != 8 -#endif /* NBBY == 8 */ - } - } -break; -case 9: -#line 237 "ftp.y" - { - switch (yystack.l_mark[-1].ival) { - - case STRU_F: - reply(200, "STRU F ok."); - break; - - default: - reply(504, "Unimplemented STRU type."); - } - } -break; -case 10: -#line 249 "ftp.y" - { - switch (yystack.l_mark[-1].ival) { - - case MODE_S: - reply(200, "MODE S ok."); - break; - - default: - reply(502, "Unimplemented MODE type."); - } - } -break; -case 11: -#line 261 "ftp.y" - { - reply(202, "ALLO command ignored."); - } -break; -case 12: -#line 265 "ftp.y" - { - reply(202, "ALLO command ignored."); - } -break; -case 13: -#line 269 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - retrieve((char *) 0, yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free(yystack.l_mark[-1].sval); - } -break; -case 14: -#line 276 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - store(yystack.l_mark[-1].sval, "w", 0); - if (yystack.l_mark[-1].sval != 0) - free(yystack.l_mark[-1].sval); - } -break; -case 15: -#line 283 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - store(yystack.l_mark[-1].sval, "a", 0); - if (yystack.l_mark[-1].sval != 0) - free(yystack.l_mark[-1].sval); - } -break; -case 16: -#line 290 "ftp.y" - { - if (yystack.l_mark[-1].ival) - send_file_list("."); - } -break; -case 17: -#line 295 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - send_file_list((char *) yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 18: -#line 302 "ftp.y" - { - if (yystack.l_mark[-1].ival) - retrieve("/bin/ls -lgA", ""); - } -break; -case 19: -#line 307 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - retrieve("/bin/ls -lgA %s", yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free(yystack.l_mark[-1].sval); - } -break; -case 20: -#line 314 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - statfilecmd(yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free(yystack.l_mark[-1].sval); - } -break; -case 21: -#line 321 "ftp.y" - { - statcmd(); - } -break; -case 22: -#line 325 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - remove((char *) yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 23: -#line 332 "ftp.y" - { - if (fromname) { - renamecmd(fromname, (char *) yystack.l_mark[-1].sval); - free(fromname); - fromname = (char *) 0; - } else { - reply(503, "Bad sequence of commands."); - } - free((char *) yystack.l_mark[-1].sval); - } -break; -case 24: -#line 343 "ftp.y" - { - reply(225, "ABOR command successful."); - } -break; -case 25: -#line 347 "ftp.y" - { - if (yystack.l_mark[-1].ival) - cwd(pw->pw_dir); - } -break; -case 26: -#line 352 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - cwd((char *) yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 27: -#line 359 "ftp.y" - { - help(cmdtab, (char *) 0); - } -break; -case 28: -#line 363 "ftp.y" - { - register char *cp = (char *)yystack.l_mark[-1].sval; - - if (strncasecmp(cp, "SITE", 4) == 0) { - cp = (char *)yystack.l_mark[-1].sval + 4; - if (*cp == ' ') - cp++; - if (*cp) - help(sitetab, cp); - else - help(sitetab, (char *) 0); - } else - help(cmdtab, (char *) yystack.l_mark[-1].sval); - } -break; -case 29: -#line 378 "ftp.y" - { - reply(200, "NOOP command successful."); - } -break; -case 30: -#line 382 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - makedir((char *) yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 31: -#line 389 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - removedir((char *) yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 32: -#line 396 "ftp.y" - { - if (yystack.l_mark[-1].ival) - pwd(); - } -break; -case 33: -#line 401 "ftp.y" - { - if (yystack.l_mark[-1].ival) - cwd(".."); - } -break; -case 34: -#line 406 "ftp.y" - { - help(sitetab, (char *) 0); - } -break; -case 35: -#line 410 "ftp.y" - { - help(sitetab, (char *) yystack.l_mark[-1].sval); - } -break; -case 36: -#line 414 "ftp.y" - { - int oldmask; - - if (yystack.l_mark[-1].ival) { - oldmask = umask(0); - (void) umask(oldmask); - reply(200, "Current UMASK is %03o", oldmask); - } - } -break; -case 37: -#line 424 "ftp.y" - { - int oldmask; - - if (yystack.l_mark[-3].ival) { - if ((yystack.l_mark[-1].ival == -1) || (yystack.l_mark[-1].ival > 0777)) { - reply(501, "Bad UMASK value"); - } else { - oldmask = umask(yystack.l_mark[-1].ival); - reply(200, - "UMASK set to %03o (was %03o)", - yystack.l_mark[-1].ival, oldmask); - } - } - } -break; -case 38: -#line 439 "ftp.y" - { - if (yystack.l_mark[-5].ival && (yystack.l_mark[-1].sval != 0)) { - if (yystack.l_mark[-3].ival > 0777) - reply(501, - "CHMOD: Mode value must be between 0 and 0777"); - else if (chmod((char *) yystack.l_mark[-1].sval, yystack.l_mark[-3].ival) < 0) - perror_reply(550, (char *) yystack.l_mark[-1].sval); - else - reply(200, "CHMOD command successful."); - } - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 39: -#line 453 "ftp.y" - { - reply(200, - "Current IDLE time limit is %d seconds; max %d", - timeout, maxtimeout); - } -break; -case 40: -#line 459 "ftp.y" - { - if (yystack.l_mark[-1].ival < 30 || yystack.l_mark[-1].ival > maxtimeout) { - reply(501, - "Maximum IDLE time must be between 30 and %d seconds", - maxtimeout); - } else { - timeout = yystack.l_mark[-1].ival; - (void) alarm((unsigned) timeout); - reply(200, - "Maximum IDLE time set to %d seconds", - timeout); - } - } -break; -case 41: -#line 473 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - store((char *) yystack.l_mark[-1].sval, "w", 1); - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 42: -#line 480 "ftp.y" - { -#ifdef unix -#ifdef BSD - reply(215, "UNIX Type: L%d Version: BSD-%d", - NBBY, BSD); -#else /* BSD */ - reply(215, "UNIX Type: L%d", NBBY); -#endif /* BSD */ -#else /* unix */ - reply(215, "UNKNOWN Type: L%d", NBBY); -#endif /* unix */ - } -break; -case 43: -#line 501 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) - sizecmd((char *) yystack.l_mark[-1].sval); - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 44: -#line 518 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval != 0) { - struct stat stbuf; - if (stat((char *) yystack.l_mark[-1].sval, &stbuf) < 0) - perror_reply(550, "%s", (char *) yystack.l_mark[-1].sval); - else if ((stbuf.st_mode&S_IFMT) != S_IFREG) { - reply(550, "%s: not a plain file.", - (char *) yystack.l_mark[-1].sval); - } else { - register struct tm *t; - t = gmtime(&stbuf.st_mtime); - reply(213, - "%04d%02d%02d%02d%02d%02d", - 1900 + t->tm_year, - t->tm_mon+1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); - } - } - if (yystack.l_mark[-1].sval != 0) - free((char *) yystack.l_mark[-1].sval); - } -break; -case 45: -#line 540 "ftp.y" - { - reply(221, "Goodbye."); - dologout(0); - } -break; -case 46: -#line 545 "ftp.y" - { - yyerrok; - } -break; -case 47: -#line 550 "ftp.y" - { - if (yystack.l_mark[-3].ival && yystack.l_mark[-1].sval) { - fromname = renamefrom((char *) yystack.l_mark[-1].sval); - if (fromname == (char *) 0 && yystack.l_mark[-1].sval) { - free((char *) yystack.l_mark[-1].sval); - } - } - } -break; -case 49: -#line 564 "ftp.y" - { - *(const char **)(&(yyval.sval)) = ""; - } -break; -case 52: -#line 575 "ftp.y" - { - register char *a, *p; - - a = (char *)&data_dest.sin_addr; - a[0] = (char) yystack.l_mark[-10].ival; - a[1] = (char) yystack.l_mark[-8].ival; - a[2] = (char) yystack.l_mark[-6].ival; - a[3] = (char) yystack.l_mark[-4].ival; - p = (char *)&data_dest.sin_port; - p[0] = (char) yystack.l_mark[-2].ival; - p[1] = (char) yystack.l_mark[0].ival; - data_dest.sin_family = AF_INET; - } -break; -case 53: -#line 591 "ftp.y" - { - yyval.ival = FORM_N; - } -break; -case 54: -#line 595 "ftp.y" - { - yyval.ival = FORM_T; - } -break; -case 55: -#line 599 "ftp.y" - { - yyval.ival = FORM_C; - } -break; -case 56: -#line 605 "ftp.y" - { - cmd_type = TYPE_A; - cmd_form = FORM_N; - } -break; -case 57: -#line 610 "ftp.y" - { - cmd_type = TYPE_A; - cmd_form = yystack.l_mark[0].ival; - } -break; -case 58: -#line 615 "ftp.y" - { - cmd_type = TYPE_E; - cmd_form = FORM_N; - } -break; -case 59: -#line 620 "ftp.y" - { - cmd_type = TYPE_E; - cmd_form = yystack.l_mark[0].ival; - } -break; -case 60: -#line 625 "ftp.y" - { - cmd_type = TYPE_I; - } -break; -case 61: -#line 629 "ftp.y" - { - cmd_type = TYPE_L; - cmd_bytesz = NBBY; - } -break; -case 62: -#line 634 "ftp.y" - { - cmd_type = TYPE_L; - cmd_bytesz = yystack.l_mark[0].ival; - } -break; -case 63: -#line 640 "ftp.y" - { - cmd_type = TYPE_L; - cmd_bytesz = yystack.l_mark[0].ival; - } -break; -case 64: -#line 647 "ftp.y" - { - yyval.ival = STRU_F; - } -break; -case 65: -#line 651 "ftp.y" - { - yyval.ival = STRU_R; - } -break; -case 66: -#line 655 "ftp.y" - { - yyval.ival = STRU_P; - } -break; -case 67: -#line 661 "ftp.y" - { - yyval.ival = MODE_S; - } -break; -case 68: -#line 665 "ftp.y" - { - yyval.ival = MODE_B; - } -break; -case 69: -#line 669 "ftp.y" - { - yyval.ival = MODE_C; - } -break; -case 70: -#line 675 "ftp.y" - { - /* - * Problem: this production is used for all pathname - * processing, but only gives a 550 error reply. - * This is a valid reply in some cases but not in others. - */ - if (logged_in && yystack.l_mark[0].sval && strncmp((char *) yystack.l_mark[0].sval, "~", 1) == 0) { - *(char **)&(yyval.sval) = *glob((char *) yystack.l_mark[0].sval); - if (globerr != 0) { - reply(550, globerr); - yyval.sval = 0; - } - free((char *) yystack.l_mark[0].sval); - } else - yyval.sval = yystack.l_mark[0].sval; - } -break; -case 72: -#line 697 "ftp.y" - { - register int ret, dec, multby, digit; - - /* - * Convert a number that was read as decimal number - * to what it would be if it had been read as octal. - */ - dec = yystack.l_mark[0].ival; - multby = 1; - ret = 0; - while (dec) { - digit = dec%10; - if (digit > 7) { - ret = -1; - break; - } - ret += digit * multby; - multby *= 8; - dec /= 10; - } - yyval.ival = ret; - } -break; -case 73: -#line 722 "ftp.y" - { - if (logged_in) - yyval.ival = 1; - else { - reply(530, "Please login with USER and PASS."); - yyval.ival = 0; - } - } -break; -#line 1950 "ftp.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 = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - 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/contrib/byacc/test/ftp.tab.h b/contrib/byacc/test/ftp.tab.h deleted file mode 100644 index 6e72663b3..000000000 --- a/contrib/byacc/test/ftp.tab.h +++ /dev/null @@ -1,76 +0,0 @@ -#define NUMBER 257 -#define STRING 258 -#define A 259 -#define B 260 -#define C 261 -#define E 262 -#define F 263 -#define I 264 -#define L 265 -#define N 266 -#define P 267 -#define R 268 -#define S 269 -#define T 270 -#define SP 271 -#define CRLF 272 -#define COMMA 273 -#define USER 274 -#define PASS 275 -#define ACCT 276 -#define REIN 277 -#define QUIT 278 -#define PORT 279 -#define PASV 280 -#define TYPE 281 -#define STRU 282 -#define MODE 283 -#define RETR 284 -#define STOR 285 -#define APPE 286 -#define MLFL 287 -#define MAIL 288 -#define MSND 289 -#define MSOM 290 -#define MSAM 291 -#define MRSQ 292 -#define MRCP 293 -#define ALLO 294 -#define REST 295 -#define RNFR 296 -#define RNTO 297 -#define ABOR 298 -#define DELE 299 -#define CWD 300 -#define LIST 301 -#define NLST 302 -#define SITE 303 -#define STAT 304 -#define HELP 305 -#define NOOP 306 -#define MKD 307 -#define RMD 308 -#define PWD 309 -#define CDUP 310 -#define STOU 311 -#define SMNT 312 -#define SYST 313 -#define SIZE 314 -#define MDTM 315 -#define UMASK 316 -#define IDLE 317 -#define CHMOD 318 -#define LEXERR 319 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -typedef union -{ - int ival; - char *sval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE ftp_lval; diff --git a/contrib/byacc/test/ftp.y b/contrib/byacc/test/ftp.y deleted file mode 100644 index c095b3e19..000000000 --- a/contrib/byacc/test/ftp.y +++ /dev/null @@ -1,1254 +0,0 @@ -/* - * Copyright (c) 1985, 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89 - */ - -/* - * Grammar for FTP commands. - * See RFC 959. - */ - -%{ - -/* sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89"; */ - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *); -#endif - -extern struct sockaddr_in data_dest; -extern int logged_in; -extern struct passwd *pw; -extern int guest; -extern int logging; -extern int type; -extern int form; -extern int debug; -extern int timeout; -extern int maxtimeout; -extern int pdata; -extern char hostname[], remotehost[]; -extern char proctitle[]; -extern char *globerr; -extern int usedefault; -extern int transflag; -extern char tmpline[]; - -extern char **glob(char *); -extern char *renamefrom(char *); -extern void cwd(const char *); - -extern void dologout(int); -extern void fatal(const char *); -extern void makedir(const char *); -extern void nack(const char *); -extern void pass(const char *); -extern void passive(void); -extern void pwd(void); -extern void removedir(char *); -extern void renamecmd(char *, char *); -extern void retrieve(const char *, const char *); -extern void send_file_list(const char *); -extern void statcmd(void); -extern void statfilecmd(const char *); -extern void store(char *, const char *, int); -extern void user(const char *); - -extern void perror_reply(int, const char *, ...); -extern void reply(int, const char *, ...); -extern void lreply(int, const char *, ...); - -static int cmd_type; -static int cmd_form; -static int cmd_bytesz; -char cbuf[512]; -char *fromname; - -struct tab { - const char *name; - short token; - short state; - short implemented; /* 1 if command is implemented */ - const char *help; -}; - -static char * copy(const char *); - -#ifdef YYBISON -static void sizecmd(char *filename); -static void help(struct tab *ctab, char *s); -struct tab cmdtab[]; -struct tab sitetab[]; -#endif - -static void -yyerror(const char *msg) -{ - perror(msg); -} -%} - -%union -{ - int ival; - char *sval; -} -%token NUMBER -%token STRING - -%type - byte_size - check_login - form_code - mode_code - octal_number - struct_code - -%type - password - pathname - pathstring - username - -%token - A B C E F I - L N P R S T - - SP CRLF COMMA STRING NUMBER - - USER PASS ACCT REIN QUIT PORT - PASV TYPE STRU MODE RETR STOR - APPE MLFL MAIL MSND MSOM MSAM - MRSQ MRCP ALLO REST RNFR RNTO - ABOR DELE CWD LIST NLST SITE - STAT HELP NOOP MKD RMD PWD - CDUP STOU SMNT SYST SIZE MDTM - - UMASK IDLE CHMOD - - LEXERR - -%start cmd_list - -%% - -cmd_list: /* empty */ - | cmd_list cmd - { - fromname = (char *) 0; - } - | cmd_list rcmd - ; - -cmd: USER SP username CRLF - { - user($3); - free($3); - } - | PASS SP password CRLF - { - pass($3); - free($3); - } - | PORT SP host_port CRLF - { - usedefault = 0; - if (pdata >= 0) { - (void) close(pdata); - pdata = -1; - } - reply(200, "PORT command successful."); - } - | PASV CRLF - { - passive(); - } - | TYPE SP type_code CRLF - { - switch (cmd_type) { - - case TYPE_A: - if (cmd_form == FORM_N) { - reply(200, "Type set to A."); - type = cmd_type; - form = cmd_form; - } else - reply(504, "Form must be N."); - break; - - case TYPE_E: - reply(504, "Type E not implemented."); - break; - - case TYPE_I: - reply(200, "Type set to I."); - type = cmd_type; - break; - - case TYPE_L: -#if NBBY == 8 - if (cmd_bytesz == 8) { - reply(200, - "Type set to L (byte size 8)."); - type = cmd_type; - } else - reply(504, "Byte size must be 8."); -#else /* NBBY == 8 */ - UNIMPLEMENTED for NBBY != 8 -#endif /* NBBY == 8 */ - } - } - | STRU SP struct_code CRLF - { - switch ($3) { - - case STRU_F: - reply(200, "STRU F ok."); - break; - - default: - reply(504, "Unimplemented STRU type."); - } - } - | MODE SP mode_code CRLF - { - switch ($3) { - - case MODE_S: - reply(200, "MODE S ok."); - break; - - default: - reply(502, "Unimplemented MODE type."); - } - } - | ALLO SP NUMBER CRLF - { - reply(202, "ALLO command ignored."); - } - | ALLO SP NUMBER SP R SP NUMBER CRLF - { - reply(202, "ALLO command ignored."); - } - | RETR check_login SP pathname CRLF - { - if ($2 && $4 != 0) - retrieve((char *) 0, $4); - if ($4 != 0) - free($4); - } - | STOR check_login SP pathname CRLF - { - if ($2 && $4 != 0) - store($4, "w", 0); - if ($4 != 0) - free($4); - } - | APPE check_login SP pathname CRLF - { - if ($2 && $4 != 0) - store($4, "a", 0); - if ($4 != 0) - free($4); - } - | NLST check_login CRLF - { - if ($2) - send_file_list("."); - } - | NLST check_login SP STRING CRLF - { - if ($2 && $4 != 0) - send_file_list((char *) $4); - if ($4 != 0) - free((char *) $4); - } - | LIST check_login CRLF - { - if ($2) - retrieve("/bin/ls -lgA", ""); - } - | LIST check_login SP pathname CRLF - { - if ($2 && $4 != 0) - retrieve("/bin/ls -lgA %s", $4); - if ($4 != 0) - free($4); - } - | STAT check_login SP pathname CRLF - { - if ($2 && $4 != 0) - statfilecmd($4); - if ($4 != 0) - free($4); - } - | STAT CRLF - { - statcmd(); - } - | DELE check_login SP pathname CRLF - { - if ($2 && $4 != 0) - remove((char *) $4); - if ($4 != 0) - free((char *) $4); - } - | RNTO SP pathname CRLF - { - if (fromname) { - renamecmd(fromname, (char *) $3); - free(fromname); - fromname = (char *) 0; - } else { - reply(503, "Bad sequence of commands."); - } - free((char *) $3); - } - | ABOR CRLF - { - reply(225, "ABOR command successful."); - } - | CWD check_login CRLF - { - if ($2) - cwd(pw->pw_dir); - } - | CWD check_login SP pathname CRLF - { - if ($2 && $4 != 0) - cwd((char *) $4); - if ($4 != 0) - free((char *) $4); - } - | HELP CRLF - { - help(cmdtab, (char *) 0); - } - | HELP SP STRING CRLF - { - register char *cp = (char *)$3; - - if (strncasecmp(cp, "SITE", 4) == 0) { - cp = (char *)$3 + 4; - if (*cp == ' ') - cp++; - if (*cp) - help(sitetab, cp); - else - help(sitetab, (char *) 0); - } else - help(cmdtab, (char *) $3); - } - | NOOP CRLF - { - reply(200, "NOOP command successful."); - } - | MKD check_login SP pathname CRLF - { - if ($2 && $4 != 0) - makedir((char *) $4); - if ($4 != 0) - free((char *) $4); - } - | RMD check_login SP pathname CRLF - { - if ($2 && $4 != 0) - removedir((char *) $4); - if ($4 != 0) - free((char *) $4); - } - | PWD check_login CRLF - { - if ($2) - pwd(); - } - | CDUP check_login CRLF - { - if ($2) - cwd(".."); - } - | SITE SP HELP CRLF - { - help(sitetab, (char *) 0); - } - | SITE SP HELP SP STRING CRLF - { - help(sitetab, (char *) $5); - } - | SITE SP UMASK check_login CRLF - { - int oldmask; - - if ($4) { - oldmask = umask(0); - (void) umask(oldmask); - reply(200, "Current UMASK is %03o", oldmask); - } - } - | SITE SP UMASK check_login SP octal_number CRLF - { - int oldmask; - - if ($4) { - if (($6 == -1) || ($6 > 0777)) { - reply(501, "Bad UMASK value"); - } else { - oldmask = umask($6); - reply(200, - "UMASK set to %03o (was %03o)", - $6, oldmask); - } - } - } - | SITE SP CHMOD check_login SP octal_number SP pathname CRLF - { - if ($4 && ($8 != 0)) { - if ($6 > 0777) - reply(501, - "CHMOD: Mode value must be between 0 and 0777"); - else if (chmod((char *) $8, $6) < 0) - perror_reply(550, (char *) $8); - else - reply(200, "CHMOD command successful."); - } - if ($8 != 0) - free((char *) $8); - } - | SITE SP IDLE CRLF - { - reply(200, - "Current IDLE time limit is %d seconds; max %d", - timeout, maxtimeout); - } - | SITE SP IDLE SP NUMBER CRLF - { - if ($5 < 30 || $5 > maxtimeout) { - reply(501, - "Maximum IDLE time must be between 30 and %d seconds", - maxtimeout); - } else { - timeout = $5; - (void) alarm((unsigned) timeout); - reply(200, - "Maximum IDLE time set to %d seconds", - timeout); - } - } - | STOU check_login SP pathname CRLF - { - if ($2 && $4 != 0) - store((char *) $4, "w", 1); - if ($4 != 0) - free((char *) $4); - } - | SYST CRLF - { -#ifdef unix -#ifdef BSD - reply(215, "UNIX Type: L%d Version: BSD-%d", - NBBY, BSD); -#else /* BSD */ - reply(215, "UNIX Type: L%d", NBBY); -#endif /* BSD */ -#else /* unix */ - reply(215, "UNKNOWN Type: L%d", NBBY); -#endif /* unix */ - } - - /* - * SIZE is not in RFC959, but Postel has blessed it and - * it will be in the updated RFC. - * - * Return size of file in a format suitable for - * using with RESTART (we just count bytes). - */ - | SIZE check_login SP pathname CRLF - { - if ($2 && $4 != 0) - sizecmd((char *) $4); - if ($4 != 0) - free((char *) $4); - } - - /* - * MDTM is not in RFC959, but Postel has blessed it and - * it will be in the updated RFC. - * - * Return modification time of file as an ISO 3307 - * style time. E.g. YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx - * where xxx is the fractional second (of any precision, - * not necessarily 3 digits) - */ - | MDTM check_login SP pathname CRLF - { - if ($2 && $4 != 0) { - struct stat stbuf; - if (stat((char *) $4, &stbuf) < 0) - perror_reply(550, "%s", (char *) $4); - else if ((stbuf.st_mode&S_IFMT) != S_IFREG) { - reply(550, "%s: not a plain file.", - (char *) $4); - } else { - register struct tm *t; - t = gmtime(&stbuf.st_mtime); - reply(213, - "%04d%02d%02d%02d%02d%02d", - 1900 + t->tm_year, - t->tm_mon+1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); - } - } - if ($4 != 0) - free((char *) $4); - } - | QUIT CRLF - { - reply(221, "Goodbye."); - dologout(0); - } - | error CRLF - { - yyerrok; - } - ; -rcmd: RNFR check_login SP pathname CRLF - { - if ($2 && $4) { - fromname = renamefrom((char *) $4); - if (fromname == (char *) 0 && $4) { - free((char *) $4); - } - } - } - ; - -username: STRING - ; - -password: /* empty */ - { - *(const char **)(&($$)) = ""; - } - | STRING - ; - -byte_size: NUMBER - ; - -host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA - NUMBER COMMA NUMBER - { - register char *a, *p; - - a = (char *)&data_dest.sin_addr; - a[0] = (char) $1; - a[1] = (char) $3; - a[2] = (char) $5; - a[3] = (char) $7; - p = (char *)&data_dest.sin_port; - p[0] = (char) $9; - p[1] = (char) $11; - data_dest.sin_family = AF_INET; - } - ; - -form_code: N - { - $$ = FORM_N; - } - | T - { - $$ = FORM_T; - } - | C - { - $$ = FORM_C; - } - ; - -type_code: A - { - cmd_type = TYPE_A; - cmd_form = FORM_N; - } - | A SP form_code - { - cmd_type = TYPE_A; - cmd_form = $3; - } - | E - { - cmd_type = TYPE_E; - cmd_form = FORM_N; - } - | E SP form_code - { - cmd_type = TYPE_E; - cmd_form = $3; - } - | I - { - cmd_type = TYPE_I; - } - | L - { - cmd_type = TYPE_L; - cmd_bytesz = NBBY; - } - | L SP byte_size - { - cmd_type = TYPE_L; - cmd_bytesz = $3; - } - /* this is for a bug in the BBN ftp */ - | L byte_size - { - cmd_type = TYPE_L; - cmd_bytesz = $2; - } - ; - -struct_code: F - { - $$ = STRU_F; - } - | R - { - $$ = STRU_R; - } - | P - { - $$ = STRU_P; - } - ; - -mode_code: S - { - $$ = MODE_S; - } - | B - { - $$ = MODE_B; - } - | C - { - $$ = MODE_C; - } - ; - -pathname: pathstring - { - /* - * Problem: this production is used for all pathname - * processing, but only gives a 550 error reply. - * This is a valid reply in some cases but not in others. - */ - if (logged_in && $1 && strncmp((char *) $1, "~", 1) == 0) { - *(char **)&($$) = *glob((char *) $1); - if (globerr != 0) { - reply(550, globerr); - $$ = 0; - } - free((char *) $1); - } else - $$ = $1; - } - ; - -pathstring: STRING - ; - -octal_number: NUMBER - { - register int ret, dec, multby, digit; - - /* - * Convert a number that was read as decimal number - * to what it would be if it had been read as octal. - */ - dec = $1; - multby = 1; - ret = 0; - while (dec) { - digit = dec%10; - if (digit > 7) { - ret = -1; - break; - } - ret += digit * multby; - multby *= 8; - dec /= 10; - } - $$ = ret; - } - ; - -check_login: /* empty */ - { - if (logged_in) - $$ = 1; - else { - reply(530, "Please login with USER and PASS."); - $$ = 0; - } - } - ; - -%% - -#ifdef YYBYACC -extern int YYLEX_DECL(); -#endif - -extern jmp_buf errcatch; - -static void upper(char *); - -#define CMD 0 /* beginning of command */ -#define ARGS 1 /* expect miscellaneous arguments */ -#define STR1 2 /* expect SP followed by STRING */ -#define STR2 3 /* expect STRING */ -#define OSTR 4 /* optional SP then STRING */ -#define ZSTR1 5 /* SP then optional STRING */ -#define ZSTR2 6 /* optional STRING after SP */ -#define SITECMD 7 /* SITE command */ -#define NSTR 8 /* Number followed by a string */ - -struct tab cmdtab[] = { /* In order defined in RFC 765 */ - { "USER", USER, STR1, 1, " username" }, - { "PASS", PASS, ZSTR1, 1, " password" }, - { "ACCT", ACCT, STR1, 0, "(specify account)" }, - { "SMNT", SMNT, ARGS, 0, "(structure mount)" }, - { "REIN", REIN, ARGS, 0, "(reinitialize server state)" }, - { "QUIT", QUIT, ARGS, 1, "(terminate service)", }, - { "PORT", PORT, ARGS, 1, " b0, b1, b2, b3, b4" }, - { "PASV", PASV, ARGS, 1, "(set server in passive mode)" }, - { "TYPE", TYPE, ARGS, 1, " [ A | E | I | L ]" }, - { "STRU", STRU, ARGS, 1, "(specify file structure)" }, - { "MODE", MODE, ARGS, 1, "(specify transfer mode)" }, - { "RETR", RETR, STR1, 1, " file-name" }, - { "STOR", STOR, STR1, 1, " file-name" }, - { "APPE", APPE, STR1, 1, " file-name" }, - { "MLFL", MLFL, OSTR, 0, "(mail file)" }, - { "MAIL", MAIL, OSTR, 0, "(mail to user)" }, - { "MSND", MSND, OSTR, 0, "(mail send to terminal)" }, - { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" }, - { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" }, - { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" }, - { "MRCP", MRCP, STR1, 0, "(mail recipient)" }, - { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" }, - { "REST", REST, ARGS, 0, "(restart command)" }, - { "RNFR", RNFR, STR1, 1, " file-name" }, - { "RNTO", RNTO, STR1, 1, " file-name" }, - { "ABOR", ABOR, ARGS, 1, "(abort operation)" }, - { "DELE", DELE, STR1, 1, " file-name" }, - { "CWD", CWD, OSTR, 1, "[ directory-name ]" }, - { "XCWD", CWD, OSTR, 1, "[ directory-name ]" }, - { "LIST", LIST, OSTR, 1, "[ path-name ]" }, - { "NLST", NLST, OSTR, 1, "[ path-name ]" }, - { "SITE", SITE, SITECMD, 1, "site-cmd [ arguments ]" }, - { "SYST", SYST, ARGS, 1, "(get type of operating system)" }, - { "STAT", STAT, OSTR, 1, "[ path-name ]" }, - { "HELP", HELP, OSTR, 1, "[ ]" }, - { "NOOP", NOOP, ARGS, 1, "" }, - { "MKD", MKD, STR1, 1, " path-name" }, - { "XMKD", MKD, STR1, 1, " path-name" }, - { "RMD", RMD, STR1, 1, " path-name" }, - { "XRMD", RMD, STR1, 1, " path-name" }, - { "PWD", PWD, ARGS, 1, "(return current directory)" }, - { "XPWD", PWD, ARGS, 1, "(return current directory)" }, - { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" }, - { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" }, - { "STOU", STOU, STR1, 1, " file-name" }, - { "SIZE", SIZE, OSTR, 1, " path-name" }, - { "MDTM", MDTM, OSTR, 1, " path-name" }, - { 0, 0, 0, 0, 0 } -}; - -struct tab sitetab[] = { - { "UMASK", UMASK, ARGS, 1, "[ umask ]" }, - { "IDLE", IDLE, ARGS, 1, "[ maximum-idle-time ]" }, - { "CHMOD", CHMOD, NSTR, 1, " mode file-name" }, - { "HELP", HELP, OSTR, 1, "[ ]" }, - { 0, 0, 0, 0, 0 } -}; - -static struct tab * -lookup(struct tab *p, char *cmd) -{ - - for (; p->name != 0; p++) - if (strcmp(cmd, p->name) == 0) - return (p); - return (0); -} - -#include - -/* - * get_line - a hacked up version of fgets to ignore TELNET escape codes. - */ -static char * -get_line(char *s, int n, FILE *iop) -{ - register int c; - register char *cs; - - cs = s; -/* tmpline may contain saved command from urgent mode interruption */ - for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) { - *cs++ = tmpline[c]; - if (tmpline[c] == '\n') { - *cs = '\0'; - if (debug) - syslog(LOG_DEBUG, "command: %s", s); - tmpline[0] = '\0'; - return(s); - } - if (c == 0) - tmpline[0] = '\0'; - } - while ((c = getc(iop)) != EOF) { - c &= 0377; - if (c == IAC) { - if ((c = getc(iop)) != EOF) { - c &= 0377; - switch (c) { - case WILL: - case WONT: - c = getc(iop); - printf("%c%c%c", IAC, DONT, 0377&c); - (void) fflush(stdout); - continue; - case DO: - case DONT: - c = getc(iop); - printf("%c%c%c", IAC, WONT, 0377&c); - (void) fflush(stdout); - continue; - case IAC: - break; - default: - continue; /* ignore command */ - } - } - } - *cs++ = (char) c; - if (--n <= 0 || c == '\n') - break; - } - if (c == EOF && cs == s) - return (0); - *cs = '\0'; - if (debug) - syslog(LOG_DEBUG, "command: %s", s); - return (s); -} - -static void -toolong(int sig) -{ - time_t now; - - (void) sig; - reply(421, - "Timeout (%d seconds): closing control connection.", timeout); - (void) time(&now); - if (logging) { - syslog(LOG_INFO, - "User %s timed out after %d seconds at %s", - (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now)); - } - dologout(1); -} - -int -yylex(void) -{ - static int cpos, state; - register char *cp, *cp2; - register struct tab *p; - int n; - char c; - - for (;;) { - switch (state) { - - case CMD: - (void) signal(SIGALRM, toolong); - (void) alarm((unsigned) timeout); - if (get_line(cbuf, sizeof(cbuf)-1, stdin) == 0) { - reply(221, "You could at least say goodbye."); - dologout(0); - } - (void) alarm(0); -#ifdef SETPROCTITLE - if (strncasecmp(cbuf, "PASS", 4) != 0) - setproctitle("%s: %s", proctitle, cbuf); -#endif /* SETPROCTITLE */ - if ((cp = strchr(cbuf, '\r'))) { - *cp++ = '\n'; - *cp = '\0'; - } - if ((cp = strpbrk(cbuf, " \n"))) - cpos = (int) (cp - cbuf); - if (cpos == 0) - cpos = 4; - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - upper(cbuf); - p = lookup(cmdtab, cbuf); - cbuf[cpos] = c; - if (p != 0) { - if (p->implemented == 0) { - nack(p->name); - longjmp(errcatch,0); - /* NOTREACHED */ - } - state = p->state; - *(const char **)(&yylval) = p->name; - return (p->token); - } - break; - - case SITECMD: - if (cbuf[cpos] == ' ') { - cpos++; - return (SP); - } - cp = &cbuf[cpos]; - if ((cp2 = strpbrk(cp, " \n"))) - cpos = (int) (cp2 - cbuf); - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - upper(cp); - p = lookup(sitetab, cp); - cbuf[cpos] = c; - if (p != 0) { - if (p->implemented == 0) { - state = CMD; - nack(p->name); - longjmp(errcatch,0); - /* NOTREACHED */ - } - state = p->state; - *(const char **)(&yylval) = p->name; - return (p->token); - } - state = CMD; - break; - - case OSTR: - if (cbuf[cpos] == '\n') { - state = CMD; - return (CRLF); - } - /* FALLTHROUGH */ - - case STR1: - case ZSTR1: - dostr1: - if (cbuf[cpos] == ' ') { - cpos++; - if (state == OSTR) - state = STR2; - else - ++state; - return (SP); - } - break; - - case ZSTR2: - if (cbuf[cpos] == '\n') { - state = CMD; - return (CRLF); - } - /* FALLTHROUGH */ - - case STR2: - cp = &cbuf[cpos]; - n = (int) strlen(cp); - cpos += n - 1; - /* - * Make sure the string is nonempty and \n terminated. - */ - if (n > 1 && cbuf[cpos] == '\n') { - cbuf[cpos] = '\0'; - *(char **)&yylval = copy(cp); - cbuf[cpos] = '\n'; - state = ARGS; - return (STRING); - } - break; - - case NSTR: - if (cbuf[cpos] == ' ') { - cpos++; - return (SP); - } - if (isdigit(cbuf[cpos])) { - cp = &cbuf[cpos]; - while (isdigit(cbuf[++cpos])) - ; - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - yylval.ival = atoi(cp); - cbuf[cpos] = c; - state = STR1; - return (NUMBER); - } - state = STR1; - goto dostr1; - - case ARGS: - if (isdigit(cbuf[cpos])) { - cp = &cbuf[cpos]; - while (isdigit(cbuf[++cpos])) - ; - c = cbuf[cpos]; - cbuf[cpos] = '\0'; - yylval.ival = atoi(cp); - cbuf[cpos] = c; - return (NUMBER); - } - switch (cbuf[cpos++]) { - - case '\n': - state = CMD; - return (CRLF); - - case ' ': - return (SP); - - case ',': - return (COMMA); - - case 'A': - case 'a': - return (A); - - case 'B': - case 'b': - return (B); - - case 'C': - case 'c': - return (C); - - case 'E': - case 'e': - return (E); - - case 'F': - case 'f': - return (F); - - case 'I': - case 'i': - return (I); - - case 'L': - case 'l': - return (L); - - case 'N': - case 'n': - return (N); - - case 'P': - case 'p': - return (P); - - case 'R': - case 'r': - return (R); - - case 'S': - case 's': - return (S); - - case 'T': - case 't': - return (T); - - } - break; - - default: - fatal("Unknown state in scanner."); - } - yyerror((char *) 0); - state = CMD; - longjmp(errcatch,0); - } -} - -static void -upper(char *s) -{ - while (*s != '\0') { - if (islower(*s)) - *s = toupper(*s); - s++; - } -} - -static char * -copy(const char *s) -{ - char *p; - - p = (char * )malloc(strlen(s) + 1); - if (p == 0) - fatal("Ran out of memory."); - else - (void) strcpy(p, s); - return (p); -} - -static void -help(struct tab *ctab, char *s) -{ - register struct tab *c; - register int width, NCMDS; - const char *help_type; - - if (ctab == sitetab) - help_type = "SITE "; - else - help_type = ""; - width = 0, NCMDS = 0; - for (c = ctab; c->name != 0; c++) { - int len = (int) strlen(c->name); - - if (len > width) - width = len; - NCMDS++; - } - width = (width + 8) &~ 7; - if (s == 0) { - register int i, j, w; - int columns, lines; - - lreply(214, "The following %scommands are recognized %s.", - help_type, "(* =>'s unimplemented)"); - columns = 76 / width; - if (columns == 0) - columns = 1; - lines = (NCMDS + columns - 1) / columns; - for (i = 0; i < lines; i++) { - printf(" "); - for (j = 0; j < columns; j++) { - c = ctab + j * lines + i; - assert(c->name != 0); - printf("%s%c", c->name, - c->implemented ? ' ' : '*'); - if (c + lines >= &ctab[NCMDS]) - break; - w = (int) strlen(c->name) + 1; - while (w < width) { - putchar(' '); - w++; - } - } - printf("\r\n"); - } - (void) fflush(stdout); - reply(214, "Direct comments to ftp-bugs@%s.", hostname); - return; - } - upper(s); - c = lookup(ctab, s); - if (c == (struct tab *)0) { - reply(502, "Unknown command %s.", s); - return; - } - if (c->implemented) - reply(214, "Syntax: %s%s %s", help_type, c->name, c->help); - else - reply(214, "%s%-*s\t%s; unimplemented.", help_type, width, - c->name, c->help); -} - -static void -sizecmd(char *filename) -{ - switch (type) { - case TYPE_L: - case TYPE_I: { - struct stat stbuf; - if (stat(filename, &stbuf) < 0 || - (stbuf.st_mode&S_IFMT) != S_IFREG) - reply(550, "%s: not a plain file.", filename); - else -#ifdef HAVE_LONG_LONG - reply(213, "%llu", (long long) stbuf.st_size); -#else - reply(213, "%lu", stbuf.st_size); -#endif - break;} - case TYPE_A: { - FILE *fin; - register int c, count; - struct stat stbuf; - fin = fopen(filename, "r"); - if (fin == 0) { - perror_reply(550, filename); - return; - } - if (fstat(fileno(fin), &stbuf) < 0 || - (stbuf.st_mode&S_IFMT) != S_IFREG) { - reply(550, "%s: not a plain file.", filename); - (void) fclose(fin); - return; - } - - count = 0; - while((c=getc(fin)) != EOF) { - if (c == '\n') /* will get expanded to \r\n */ - count++; - count++; - } - (void) fclose(fin); - - reply(213, "%ld", count); - break;} - default: - reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]); - } -} diff --git a/contrib/byacc/test/inherit0.y b/contrib/byacc/test/inherit0.y new file mode 100644 index 000000000..3a90e45c8 --- /dev/null +++ b/contrib/byacc/test/inherit0.y @@ -0,0 +1,48 @@ +%{ +extern void mksymbol(int t, int c, int id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%start declaration + +%% +declaration: class type namelist + { $$ = $3; } + | type locnamelist + { $$ = $2; } + ; + +class : GLOBAL { $$ = 1; } + | LOCAL { $$ = 2; } + ; + +type : REAL { $$ = 1; } + | INTEGER { $$ = 2; } + ; + +namelist: namelist NAME + { mksymbol($0, $-1, $2); } + | NAME + { mksymbol($0, $-1, $1); } + ; + +locnamelist: + { $$ = 2; } /* set up semantic stack for : LOCAL */ + { $$ = $-1; } /* copy to where expects it */ + namelist + { $$ = $3; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/contrib/byacc/test/inherit1.y b/contrib/byacc/test/inherit1.y new file mode 100644 index 000000000..9c7e876f0 --- /dev/null +++ b/contrib/byacc/test/inherit1.y @@ -0,0 +1,76 @@ +%{ +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%type declaration namelist locnamelist +%type class +%type type + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist + { $$ = $3; } + | type locnamelist + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist: namelist NAME + { $$->s = mksymbol($0, $-1, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol($0, $-1, $1); + $$->next = NULL; + } + ; + +locnamelist: + { $$ = cLOCAL; } /* set up semantic stack for = LOCAL */ + { $$ = $-1; } /* copy to where expects it */ + namelist + { $$ = $3; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/contrib/byacc/test/inherit2.y b/contrib/byacc/test/inherit2.y new file mode 100644 index 000000000..e297d08cd --- /dev/null +++ b/contrib/byacc/test/inherit2.y @@ -0,0 +1,80 @@ +%{ +#include + +typedef enum {cGLOBAL, cLOCAL} class; +typedef enum {tREAL, tINTEGER} type; +typedef char * name; + +struct symbol { class c; type t; name id; }; +typedef struct symbol symbol; + +struct namelist { symbol *s; struct namelist *next; }; +typedef struct namelist namelist; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +%} + +%token GLOBAL LOCAL +%token REAL INTEGER +%token NAME + +%type declaration namelist(, ) locnamelist() +%type class +%type type + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist($1, $2) + { $$ = $3; } + | type locnamelist($1) + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist($c, $t): namelist NAME + { $$->s = mksymbol($t, $c, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol($t, $c, $1); + $$->next = NULL; + } + ; + +locnamelist($t): namelist(cLOCAL, $t) + { $$ = $1; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/contrib/byacc/test/ok_syntax1.y b/contrib/byacc/test/ok_syntax1.y new file mode 100644 index 000000000..a22f231ef --- /dev/null +++ b/contrib/byacc/test/ok_syntax1.y @@ -0,0 +1,155 @@ +%pure_parser + +%parse_param { int regs[26] } +%parse_param { int *base } + +%lex_param { int *base } + +%{ +# include +# include + +#ifdef YYBISON +#define YYSTYPE int +#define YYLEX_PARAM base +#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM) +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +%} + +%start list + +%token DIGIT LETTER + +%token OCT1 '\177' +%token HEX1 '\xff' +%token HEX2 '\xFF' +%token HEX3 '\x7f' +%token STR1 "\x7f\177\\\n" +%token STR2 "\x7f\ +\177\\\n" + +%token BELL '\a' +%token BS '\b' +%token NL '\n' +%token LF '\f' +%token CR '\r' +%token TAB '\t' +%token VT '\v' + +%union +{ + char * cval; + int ival; + double dval; +} + +%0 '@' +%2 '~' +%> '^' +%< '#' + +%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 */ + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main (void) +{ + int regs[26]; + int base = 10; + + while(!feof(stdin)) { + yyparse(regs, &base); + } + return 0; +} + +#define UNUSED(x) ((void)(x)) + +static void +YYERROR_DECL() +{ + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ + fprintf(stderr, "%s\n", s); +} + +int +YYLEX_DECL() +{ + /* 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->ival = (c - 'a'); + return ( LETTER ); + } + if( isdigit( c )) { + yylval->ival = (c - '0') % (*base); + return ( DIGIT ); + } + return( c ); +} diff --git a/contrib/byacc/test/run_lint.sh b/contrib/byacc/test/run_lint.sh index 323055104..cdf7739cd 100755 --- a/contrib/byacc/test/run_lint.sh +++ b/contrib/byacc/test/run_lint.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: run_lint.sh,v 1.1 2010/06/08 09:00:58 tom Exp $ +# $Id: run_lint.sh,v 1.3 2014/03/28 23:40:27 tom Exp $ # vi:ts=4 sw=4: # run lint on each of the ".c" files in the test directory @@ -13,8 +13,16 @@ else TEST_DIR=. fi +ifBTYACC=`fgrep -l 'define YYBTYACC' config.h > /dev/null; test $? != 0; echo $?` + +if test $ifBTYACC = 0; then + REF_DIR=${TEST_DIR}/yacc +else + REF_DIR=${TEST_DIR}/btyacc +fi + echo '** '`date` -for i in ${TEST_DIR}/*.c +for i in ${REF_DIR}/*.c do make -f $PROG_DIR/makefile lint C_FILES=$i srcdir=$PROG_DIR done diff --git a/contrib/byacc/test/run_make.sh b/contrib/byacc/test/run_make.sh index 2bbe95d18..218a7c52c 100755 --- a/contrib/byacc/test/run_make.sh +++ b/contrib/byacc/test/run_make.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: run_make.sh,v 1.9 2012/01/15 22:35:01 tom Exp $ +# $Id: run_make.sh,v 1.14 2014/04/06 17:50:57 tom Exp $ # vi:ts=4 sw=4: # do a test-compile on each of the ".c" files in the test-directory @@ -14,30 +14,54 @@ else PROG_DIR=.. TEST_DIR=. fi +THIS_DIR=`pwd` -MY_MAKE="make -f $PROG_DIR/makefile srcdir=$PROG_DIR VPATH=$TEST_DIR" +ifBTYACC=`fgrep -l 'define YYBTYACC' config.h > /dev/null; test $? != 0; echo $?` + +if test $ifBTYACC = 0; then + REF_DIR=${TEST_DIR}/yacc +else + REF_DIR=${TEST_DIR}/btyacc +fi + +MY_MAKE="make -f $PROG_DIR/makefile srcdir=$PROG_DIR" + +run_make() { + C_FILE=`basename "$1"` + O_FILE=`basename "$C_FILE" .c`.o + shift + cd $REF_DIR + make -f $PROG_DIR/makefile srcdir=$PROG_DIR $O_FILE $* + test -f $O_FILE && rm $O_FILE + cd $THIS_DIR +} echo '** '`date` -for input in ${TEST_DIR}/*.c +echo "** program is in $PROG_DIR" +echo "** test-files in $REF_DIR" + +for input in ${REF_DIR}/*.c do - test -f "$input" || continue + case $input in #(vi + ${REF_DIR}/err_*) + continue + ;; + esac - obj=`basename "$input" .c`.o + test -f "$input" || continue - $MY_MAKE $obj C_FILES=$input - test -f $obj && rm $obj + run_make "$input" DEFS= case $input in #(vi - ${TEST_DIR}/pure_*) + ${REF_DIR}/pure_*) # DEFS="-DYYLEX_PARAM=flag -DYYLEX_PARAM_TYPE=int" ;; esac if test "x$DEFS" != "x" then - $MY_MAKE $obj C_FILES=$input DEFINES="$DEFS" - test -f $obj && rm -f $obj + run_make "$input" DEFINES="$DEFS" fi done @@ -47,6 +71,15 @@ then for input in ${TEST_DIR}/*.y do test -f "$input" || continue + case $input in + ${TEST_DIR}/err_*) + continue + ;; + ${TEST_DIR}/btyacc_*) + # Bison does not support the btyacc []-action extension. + continue + ;; + esac # Bison does not support pure-parser from command-line. # Also, its support for %expect is generally broken. @@ -56,7 +89,7 @@ then rm -f run_make.[coy] case $input in - pure_*) + ${TEST_DIR}/pure_*) if test -z `fgrep -l '%pure-parser' $input` then echo "%pure-parser" >>run_make.y @@ -67,17 +100,20 @@ then sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y bison -y run_make.y - sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c + if test -f "y.tab.c" + then + sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c - rm -f y.tab.c + rm -f y.tab.c - input=run_make.c - object=run_make.o - if test -f $input - then - $MY_MAKE $object DEFINES='-DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=1 -DYYSTACK_USE_ALLOCA=0 -DYYMAXDEPTH=0' - else - echo "?? $input not found" + input=run_make.c + object=run_make.o + if test -f $input + then + $MY_MAKE $object DEFINES='-DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=1 -DYYSTACK_USE_ALLOCA=0 -DYYMAXDEPTH=0' + else + echo "?? $input not found" + fi fi rm -f run_make.[coy] done @@ -122,17 +158,20 @@ then sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y $YACC run_make.y - sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c + if test -f y.tab.c + then + sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c - rm -f y.tab.c + rm -f y.tab.c - input=run_make.c - object=run_make.o - if test -f $input - then - $MY_MAKE $object - else - echo "?? $input not found" + input=run_make.c + object=run_make.o + if test -f $input + then + $MY_MAKE $object + else + echo "?? $input not found" + fi fi rm -f run_make.[coy] done diff --git a/contrib/byacc/test/run_test.sh b/contrib/byacc/test/run_test.sh index ae8591b8c..d9faf0bd7 100755 --- a/contrib/byacc/test/run_test.sh +++ b/contrib/byacc/test/run_test.sh @@ -1,11 +1,61 @@ #!/bin/sh -# $Id: run_test.sh,v 1.8 2012/01/15 11:50:35 tom Exp $ +# $Id: run_test.sh,v 1.22 2014/04/09 11:00:45 tom Exp $ # vi:ts=4 sw=4: +# NEW is the file created by the testcase +# REF is the reference file against which to compare +test_diffs() { + # echo "...test_diffs $NEW vs $REF" + mv -f $NEW ${REF_DIR}/ + CMP=${REF_DIR}/${NEW} + if test ! -f $CMP + then + echo "...not found $CMP" + else + sed -e s,$NEW,$REF, \ + -e "s%$YACC%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 ",' \ + -e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \ + < $CMP >$tmpfile \ + && mv $tmpfile $CMP + if test ! -f $REF + then + mv $CMP $REF + echo "...saved $REF" + elif ( cmp -s $REF $CMP ) + then + echo "...ok $REF" + rm -f $CMP + else + echo "...diff $REF" + diff -u $REF $CMP + fi + fi +} + +test_flags() { + echo "** testing flags $*" + root=$1 + ROOT=test-$root + shift 1 + $YACC $* >$ROOT.output \ + 2>&1 >$ROOT.error + for type in .output .error + do + NEW=$ROOT$type + REF=$REF_DIR/$root$type + test_diffs + done +} + if test $# = 1 then PROG_DIR=`pwd` TEST_DIR=$1 + PROG_DIR=`echo "$PROG_DIR" | sed -e 's/ /\\\\ /g'` + TEST_DIR=`echo "$TEST_DIR" | sed -e 's/ /\\\\ /g'` else PROG_DIR=.. TEST_DIR=. @@ -14,13 +64,78 @@ fi YACC=$PROG_DIR/yacc tmpfile=temp$$ -rm -f test-* + +ifBTYACC=`fgrep -l 'define YYBTYACC' config.h > /dev/null; test $? != 0; echo $?` + +if test $ifBTYACC = 0; then + REF_DIR=${TEST_DIR}/yacc +else + REF_DIR=${TEST_DIR}/btyacc +fi + +rm -f ${REF_DIR}/test-* echo '** '`date` + +# Tests which do not need files +MYFILE=nosuchfile +test_flags help -z +test_flags big_b -B +test_flags big_l -L + +# Test attempts to read non-existent file +rm -f $MYFILE.* +test_flags nostdin - $MYFILE.y +test_flags no_opts -- $MYFILE.y + +# Test attempts to write to readonly file +touch $MYFILE.y + +touch $MYFILE.c +chmod 444 $MYFILE.* +test_flags no_b_opt -b +test_flags no_b_opt1 -bBASE -o $MYFILE.c $MYFILE.y + +touch $MYFILE.c +chmod 444 $MYFILE.* +test_flags no_p_opt -p +test_flags no_p_opt1 -pBASE -o $MYFILE.c $MYFILE.y +rm -f BASE$MYFILE.c + +touch $MYFILE.dot +chmod 444 $MYFILE.* +test_flags no_graph -g -o $MYFILE.c $MYFILE.y +rm -f $MYFILE.dot + +touch $MYFILE.output +chmod 444 $MYFILE.* +test_flags no_verbose -v -o $MYFILE.c $MYFILE.y +test_flags no_output -o $MYFILE.output $MYFILE.y +test_flags no_output1 -o$MYFILE.output $MYFILE.y +test_flags no_output2 -o +rm -f $MYFILE.output + +touch $MYFILE.h +chmod 444 $MYFILE.* +test_flags no_defines -d -o $MYFILE.c $MYFILE.y +rm -f $MYFILE.h + +touch $MYFILE.i +chmod 444 $MYFILE.* +test_flags no_include -i -o $MYFILE.c $MYFILE.y +rm -f $MYFILE.i + +touch $MYFILE.code.c +chmod 444 $MYFILE.* +test_flags no_code_c -r -o $MYFILE.c $MYFILE.y +rm -f $MYFILE.code.c + +rm -f $MYFILE.* + for input in ${TEST_DIR}/*.y do case $input in - test*) + test-*) echo "?? ignored $input" ;; *) @@ -30,8 +145,24 @@ do OPTS= OPT2= - TYPE=".output .tab.c .tab.h" + OOPT= + TYPE=".error .output .tab.c .tab.h" case $input in + ${TEST_DIR}/btyacc_*) + if test $ifBTYACC = 0; then continue; fi + OPTS="$OPTS -B" + prefix=`echo "$prefix" | sed -e 's/^btyacc_//'` + ;; + ${TEST_DIR}/grammar*) + OPTS="$OPTS -g" + TYPE="$TYPE .dot" + ;; + ${TEST_DIR}/code_debug*) + OPTS="$OPTS -t -i" + OOPT=rename_debug.c + TYPE="$TYPE .i" + prefix= + ;; ${TEST_DIR}/code_*) OPTS="$OPTS -r" TYPE="$TYPE .code.c" @@ -44,37 +175,62 @@ do ${TEST_DIR}/quote_*) OPT2="-s" ;; + ${TEST_DIR}/inherit*|\ + ${TEST_DIR}/err_inherit*) + if test $ifBTYACC = 0; then continue; fi + ;; esac + echo "** testing $input" + + test -n "$prefix" && prefix="-p $prefix" + for opt2 in "" $OPT2 do - $YACC $OPTS $opt2 -v -d -p $prefix -b $ROOT${opt2} $input + output=$OOPT + if test -n "$output" + then + output="-o $output" + error=`basename $OOPT .c`.error + else + error=${ROOT}${opt2}.error + fi + + $YACC $OPTS $opt2 -v -d $output $prefix -b $ROOT${opt2} $input 2>$error for type in $TYPE do - REF=${TEST_DIR}/${root}${opt2}${type} - CMP=${ROOT}${opt2}${type} - if test ! -f $CMP + REF=${REF_DIR}/${root}${opt2}${type} + + # handle renaming due to "-o" option + if test -n "$OOPT" then - echo "...not found $CMP" + case $type in + *.tab.c) + type=.c + ;; + *.tab.h) + type=.h + ;; + *) + ;; + esac + NEW=`basename $OOPT .c`${type} + case $NEW in + test-*) + ;; + *) + if test -f "$NEW" + then + REF=${REF_DIR}/$NEW + mv $NEW test-$NEW + NEW=test-$NEW + fi + ;; + esac else - sed -e s,$CMP,$REF, \ - -e /YYPATCH/d \ - -e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \ - < $CMP >$tmpfile \ - && mv $tmpfile $CMP - if test ! -f $REF - then - mv $CMP $REF - echo "...saved $REF" - elif ( cmp -s $REF $CMP ) - then - echo "...ok $REF" - rm -f $CMP - else - echo "...diff $REF" - diff -u $REF $CMP - fi + NEW=${ROOT}${opt2}${type} fi + test_diffs done done ;; diff --git a/contrib/byacc/test/varsyntax_calc1.y b/contrib/byacc/test/varsyntax_calc1.y new file mode 100644 index 000000000..c9917e0b4 --- /dev/null +++ b/contrib/byacc/test/varsyntax_calc1.y @@ -0,0 +1,307 @@ +%IDENT "check variant syntax features" +%{ + +// http://dinosaur.compilertools.net/yacc/index.html */ + +#include +#include +#include +#include + +typedef struct interval +{ + double lo, hi; +} +INTERVAL; + +INTERVAL vmul(double, double, INTERVAL); +INTERVAL vdiv(double, double, INTERVAL); + +extern int yylex(void); +static void yyerror(const char *s); + +int dcheck(INTERVAL); + +double dreg[26]; +INTERVAL vreg[26]; + +%} +%expect 18 + +%start line +%union +{ + int ival; // dreg & vreg array index values + double dval; // floating point values + INTERVAL vval; // interval values +} + +%token DREG VREG // indices into dreg, vreg arrays */ +%token CONST // floating point constant */ + +%type dexp // expression */ +%type vexp // interval expression */ + + // precedence information about the operators */ + +%< '+' '-' // %< is an obsolete synonym for %left +%< '*' '/' +%> UMINUS // precedence for unary minus; + // %> is an obsolete synonym for %right + +\\ // beginning of rules section; \\ is an obsolete synonym for %% + +lines : // empty */ + | lines line + ; + +line : dexp '\n' + { + (void) printf("%15.8f\n", $1); + } + | vexp '\n' + { + (void) printf("(%15.8f, %15.8f)\n", $1.lo, $1.hi); + } + | DREG '=' dexp '\n' + { + dreg[$1] = $3; + } + | VREG '=' vexp '\n' + { + vreg[$1] = $3; + } + | error '\n' + { + yyerrok; + } + ; + +dexp : CONST + | DREG + { + $$ = dreg[$1]; // $$ & $1 are sufficient here + } + | dexp '+' dexp + { + $$ = $1 + $3; + } + | dexp '-' dexp + { + $$ = $1 - $3; + } + | dexp '*' dexp + { + $$ = $1 * $3; + } + | dexp '/' dexp + { + $$ = $1 / $3; + } + | '-' dexp %prec UMINUS + { + $$ = -$2; + } + | '(' dexp ')' + { + $$ = $2; + } + ; + +vexp : dexp + { + $$.hi = $$.lo = $1; + } + | '(' dexp ',' dexp ')' + { + $$.lo = $2; + $$.hi = $4; + if ( $$.lo > $$.hi ) + { + (void) printf("interval out of order\n"); + YYERROR; + } + } + | VREG + { + $$ = vreg[$1]; + } + | vexp '+' vexp + { + $$.hi = $1.hi + $3.hi; + $$.lo = $1.lo + $3.lo; + } + | dexp '+' vexp + { + $$.hi = $1 + $3.hi; + $$.lo = $1 + $3.lo; + } + | vexp '-' vexp + { + $$.hi = $1.hi - $3.lo; + $$.lo = $1.lo - $3.hi; + } + | dexp '-' vexp + { + $$.hi = $1 - $3.lo; + $$.lo = $1 - $3.hi; + } + | vexp '*' vexp + { + $$ = vmul( $1.lo, $1.hi, $3 ); + } + | dexp '*' vexp + { + $$ = vmul ($1, $1, $3 ); + } + | vexp '/' vexp + { + if (dcheck($3)) YYERROR; + $$ = vdiv ( $1.lo, $1.hi, $3 ); + } + | dexp '/' vexp + { + if (dcheck ( $3 )) YYERROR; + $$ = vdiv ($1, $1, $3 ); + } + | '-' vexp %prec UMINUS + { + $$.hi = -$2.lo; + $$.lo = -$2.hi; + } + | '(' vexp ')' + { + $$ = $2; + } + ; + +\\ /* beginning of subroutines section */ + +#define BSZ 50 /* buffer size for floating point numbers */ + + /* lexical analysis */ + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + int c; + + while ((c = getchar()) == ' ') + { /* skip over blanks */ + } + + if (isupper(c)) + { + yylval.ival = c - 'A'; + return (VREG); + } + if (islower(c)) + { + yylval.ival = c - 'a'; + return (DREG); + } + + if (isdigit(c) || c == '.') + { + /* gobble up digits, points, exponents */ + char buf[BSZ + 1], *cp = buf; + int dot = 0, expr = 0; + + for (; (cp - buf) < BSZ; ++cp, c = getchar()) + { + + *cp = (char) c; + if (isdigit(c)) + continue; + if (c == '.') + { + if (dot++ || expr) + return ('.'); /* will cause syntax error */ + continue; + } + + if (c == 'e') + { + if (expr++) + return ('e'); /* will cause syntax error */ + continue; + } + + /* end of number */ + break; + } + *cp = '\0'; + + if ((cp - buf) >= BSZ) + printf("constant too long: truncated\n"); + else + ungetc(c, stdin); /* push back last char read */ + yylval.dval = atof(buf); + return (CONST); + } + return (c); +} + +static INTERVAL +hilo(double a, double b, double c, double d) +{ + /* returns the smallest interval containing a, b, c, and d */ + /* used by *, / routines */ + INTERVAL v; + + if (a > b) + { + v.hi = a; + v.lo = b; + } + else + { + v.hi = b; + v.lo = a; + } + + if (c > d) + { + if (c > v.hi) + v.hi = c; + if (d < v.lo) + v.lo = d; + } + else + { + if (d > v.hi) + v.hi = d; + if (c < v.lo) + v.lo = c; + } + return (v); +} + +INTERVAL +vmul(double a, double b, INTERVAL v) +{ + return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); +} + +int +dcheck(INTERVAL v) +{ + if (v.hi >= 0. && v.lo <= 0.) + { + printf("divisor interval contains 0.\n"); + return (1); + } + return (0); +} + +INTERVAL +vdiv(double a, double b, INTERVAL v) +{ + return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); +} diff --git a/contrib/byacc/test/yacc/big_b.error b/contrib/byacc/test/yacc/big_b.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/big_b.output b/contrib/byacc/test/yacc/big_b.output new file mode 100644 index 000000000..889f0130b --- /dev/null +++ b/contrib/byacc/test/yacc/big_b.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/yacc/big_l.error b/contrib/byacc/test/yacc/big_l.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/big_l.output b/contrib/byacc/test/yacc/big_l.output new file mode 100644 index 000000000..889f0130b --- /dev/null +++ b/contrib/byacc/test/yacc/big_l.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/yacc/calc.error b/contrib/byacc/test/yacc/calc.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/calc.output b/contrib/byacc/test/yacc/calc.output similarity index 100% rename from contrib/byacc/test/calc.output rename to contrib/byacc/test/yacc/calc.output diff --git a/contrib/byacc/test/calc.tab.c b/contrib/byacc/test/yacc/calc.tab.c similarity index 87% rename from contrib/byacc/test/calc.tab.c rename to contrib/byacc/test/yacc/calc.tab.c index 085c1f320..762dfa182 100644 --- a/contrib/byacc/test/calc.tab.c +++ b/contrib/byacc/test/yacc/calc.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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_parse @@ -105,10 +107,12 @@ int base; extern int yylex(void); static void yyerror(const char *s); -#line 109 "calc.tab.c" +#line 111 "calc.tab.c" -#ifndef YYSTYPE +#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 */ @@ -146,40 +150,41 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -static const short calc_lhs[] = { -1, +typedef short YYINT; +static const YYINT 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, +static const YYINT 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, +static const YYINT 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, +static const YYINT calc_dgoto[] = { 1, 7, 8, 9, }; -static const short calc_sindex[] = { 0, +static const YYINT 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, +static const YYINT 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, +static const YYINT calc_gindex[] = { 0, 0, 65, 0, }; #define YYTABLESIZE 220 -static const short calc_table[] = { 6, +static const YYINT 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, @@ -203,7 +208,7 @@ static const short calc_table[] = { 6, 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, +static const YYINT 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, @@ -232,8 +237,10 @@ static const short calc_check[] = { 40, #define YYDEBUG 0 #endif #define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const calc_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, @@ -242,9 +249,9 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const calc_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -284,18 +291,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -343,7 +350,7 @@ yylex(void) } return( c ); } -#line 347 "calc.tab.c" +#line 354 "calc.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -357,27 +364,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -427,7 +434,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -437,13 +444,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -457,7 +462,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -476,7 +481,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -497,7 +502,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -521,13 +526,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -609,7 +612,7 @@ case 18: #line 63 "calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 613 "calc.tab.c" +#line 616 "calc.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -627,19 +630,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -652,16 +653,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/calc.tab.h b/contrib/byacc/test/yacc/calc.tab.h similarity index 100% rename from contrib/byacc/test/calc.tab.h rename to contrib/byacc/test/yacc/calc.tab.h diff --git a/contrib/byacc/test/yacc/calc1.error b/contrib/byacc/test/yacc/calc1.error new file mode 100644 index 000000000..9c1f7152c --- /dev/null +++ b/contrib/byacc/test/yacc/calc1.error @@ -0,0 +1,2 @@ +YACC: 2 rules never reduced +YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/contrib/byacc/test/calc1.output b/contrib/byacc/test/yacc/calc1.output similarity index 100% rename from contrib/byacc/test/calc1.output rename to contrib/byacc/test/yacc/calc1.output diff --git a/contrib/byacc/test/calc1.tab.c b/contrib/byacc/test/yacc/calc1.tab.c similarity index 90% rename from contrib/byacc/test/calc1.tab.c rename to contrib/byacc/test/yacc/calc1.tab.c index 7db7c3042..7a5f925f9 100644 --- a/contrib/byacc/test/calc1.tab.c +++ b/contrib/byacc/test/yacc/calc1.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 calc1_parse @@ -135,7 +137,7 @@ typedef union INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ -#line 139 "calc1.tab.c" +#line 141 "calc1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM @@ -173,17 +175,18 @@ extern int YYPARSE_DECL(); #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 -static const short calc1_lhs[] = { -1, +typedef short YYINT; +static const YYINT calc1_lhs[] = { -1, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; -static const short calc1_len[] = { 2, +static const YYINT calc1_len[] = { 2, 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, }; -static const short calc1_defred[] = { 0, +static const YYINT calc1_defred[] = { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, @@ -192,10 +195,10 @@ static const short calc1_defred[] = { 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 13, 17, }; -static const short calc1_dgoto[] = { 7, +static const YYINT calc1_dgoto[] = { 7, 32, 9, 0, }; -static const short calc1_sindex[] = { -40, +static const YYINT calc1_sindex[] = { -40, -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, @@ -204,7 +207,7 @@ static const short calc1_sindex[] = { -40, -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 0, 0, }; -static const short calc1_rindex[] = { 0, +static const YYINT calc1_rindex[] = { 0, 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -213,11 +216,11 @@ static const short calc1_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 0, 0, }; -static const short calc1_gindex[] = { 0, +static const YYINT calc1_gindex[] = { 0, 4, 124, 0, }; #define YYTABLESIZE 225 -static const short calc1_table[] = { 6, +static const YYINT calc1_table[] = { 6, 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, @@ -242,7 +245,7 @@ static const short calc1_table[] = { 6, 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 14, 4, 13, 0, 4, }; -static const short calc1_check[] = { 40, +static const YYINT calc1_check[] = { 40, 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, @@ -272,8 +275,10 @@ static const short calc1_check[] = { 40, #define YYDEBUG 0 #endif #define YYMAXTOKEN 260 +#define YYUNDFTOKEN 266 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const calc1_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, @@ -282,9 +287,9 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"DREG","VREG","CONST","UMINUS", +0,0,"DREG","VREG","CONST","UMINUS",0,0,0,0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const calc1_rule[] = { "$accept : line", "lines :", "lines : lines line", @@ -334,18 +339,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -482,7 +487,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 486 "calc1.tab.c" +#line 491 "calc1.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -496,27 +501,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -566,7 +571,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -576,13 +581,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -596,7 +599,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -615,7 +618,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -636,7 +639,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -660,13 +663,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -851,7 +852,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 855 "calc1.tab.c" +#line 856 "calc1.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -869,19 +870,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -894,16 +893,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/calc1.tab.h b/contrib/byacc/test/yacc/calc1.tab.h similarity index 100% rename from contrib/byacc/test/calc1.tab.h rename to contrib/byacc/test/yacc/calc1.tab.h diff --git a/contrib/byacc/test/yacc/calc2.error b/contrib/byacc/test/yacc/calc2.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/calc2.output b/contrib/byacc/test/yacc/calc2.output similarity index 100% rename from contrib/byacc/test/calc2.output rename to contrib/byacc/test/yacc/calc2.output diff --git a/contrib/byacc/test/calc2.tab.c b/contrib/byacc/test/yacc/calc2.tab.c similarity index 87% rename from contrib/byacc/test/calc2.tab.c rename to contrib/byacc/test/yacc/calc2.tab.c index 4e988e72b..d85ea8837 100644 --- a/contrib/byacc/test/calc2.tab.c +++ b/contrib/byacc/test/yacc/calc2.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 calc2_parse @@ -107,10 +109,12 @@ int YYLEX_DECL(); static void YYERROR_DECL(); #endif -#line 111 "calc2.tab.c" +#line 113 "calc2.tab.c" -#ifndef YYSTYPE +#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 */ @@ -148,40 +152,41 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -static const short calc2_lhs[] = { -1, +typedef short YYINT; +static const YYINT calc2_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short calc2_len[] = { 2, +static const YYINT calc2_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short calc2_defred[] = { 1, +static const YYINT calc2_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 calc2_dgoto[] = { 1, +static const YYINT calc2_dgoto[] = { 1, 7, 8, 9, }; -static const short calc2_sindex[] = { 0, +static const YYINT calc2_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 calc2_rindex[] = { 0, +static const YYINT calc2_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 calc2_gindex[] = { 0, +static const YYINT calc2_gindex[] = { 0, 0, 65, 0, }; #define YYTABLESIZE 220 -static const short calc2_table[] = { 6, +static const YYINT calc2_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, @@ -205,7 +210,7 @@ static const short calc2_table[] = { 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, }; -static const short calc2_check[] = { 40, +static const YYINT calc2_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, @@ -234,8 +239,10 @@ static const short calc2_check[] = { 40, #define YYDEBUG 0 #endif #define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const calc2_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, @@ -244,9 +251,9 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const calc2_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -286,18 +293,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -322,9 +329,13 @@ main (void) return 0; } +#define UNUSED(x) ((void)(x)) + static void YYERROR_DECL() { + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ fprintf(stderr, "%s\n", s); } @@ -352,7 +363,7 @@ YYLEX_DECL() } return( c ); } -#line 356 "calc2.tab.c" +#line 367 "calc2.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -366,27 +377,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -436,7 +447,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -446,13 +457,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -466,7 +475,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -485,7 +494,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror(regs, base, "syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -506,7 +515,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -530,13 +539,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -618,7 +625,7 @@ case 18: #line 70 "calc2.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 622 "calc2.tab.c" +#line 629 "calc2.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -636,19 +643,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -661,16 +666,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror(regs, base, "yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/calc2.tab.h b/contrib/byacc/test/yacc/calc2.tab.h similarity index 100% rename from contrib/byacc/test/calc2.tab.h rename to contrib/byacc/test/yacc/calc2.tab.h diff --git a/contrib/byacc/test/yacc/calc3.error b/contrib/byacc/test/yacc/calc3.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/calc3.output b/contrib/byacc/test/yacc/calc3.output similarity index 100% rename from contrib/byacc/test/calc3.output rename to contrib/byacc/test/yacc/calc3.output diff --git a/contrib/byacc/test/calc3.tab.c b/contrib/byacc/test/yacc/calc3.tab.c similarity index 87% rename from contrib/byacc/test/calc3.tab.c rename to contrib/byacc/test/yacc/calc3.tab.c index eff5a31ef..b5ca0414f 100644 --- a/contrib/byacc/test/calc3.tab.c +++ b/contrib/byacc/test/yacc/calc3.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 calc3_parse @@ -108,10 +110,12 @@ int YYLEX_DECL(); static void YYERROR_DECL(); #endif -#line 112 "calc3.tab.c" +#line 114 "calc3.tab.c" -#ifndef YYSTYPE +#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 */ @@ -153,40 +157,41 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -static const short calc3_lhs[] = { -1, +typedef short YYINT; +static const YYINT calc3_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short calc3_len[] = { 2, +static const YYINT calc3_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short calc3_defred[] = { 1, +static const YYINT calc3_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 calc3_dgoto[] = { 1, +static const YYINT calc3_dgoto[] = { 1, 7, 8, 9, }; -static const short calc3_sindex[] = { 0, +static const YYINT calc3_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 calc3_rindex[] = { 0, +static const YYINT calc3_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 calc3_gindex[] = { 0, +static const YYINT calc3_gindex[] = { 0, 0, 65, 0, }; #define YYTABLESIZE 220 -static const short calc3_table[] = { 6, +static const YYINT calc3_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, @@ -210,7 +215,7 @@ static const short calc3_table[] = { 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, }; -static const short calc3_check[] = { 40, +static const YYINT calc3_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, @@ -239,8 +244,10 @@ static const short calc3_check[] = { 40, #define YYDEBUG 0 #endif #define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const calc3_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, @@ -249,9 +256,9 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const calc3_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -286,18 +293,18 @@ int yynerrs; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -320,9 +327,13 @@ main (void) return 0; } +#define UNUSED(x) ((void)(x)) + static void YYERROR_DECL() { + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ fprintf(stderr, "%s\n", s); } @@ -350,7 +361,7 @@ YYLEX_DECL() } return( c ); } -#line 354 "calc3.tab.c" +#line 365 "calc3.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -364,27 +375,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -441,7 +452,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -451,13 +462,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -471,7 +480,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -490,7 +499,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror(regs, base, "syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -511,7 +520,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -535,13 +544,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -623,7 +630,7 @@ case 18: #line 73 "calc3.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 627 "calc3.tab.c" +#line 634 "calc3.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -641,19 +648,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -666,16 +671,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror(regs, base, "yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/calc3.tab.h b/contrib/byacc/test/yacc/calc3.tab.h similarity index 100% rename from contrib/byacc/test/calc3.tab.h rename to contrib/byacc/test/yacc/calc3.tab.h diff --git a/contrib/byacc/test/code_calc.code.c b/contrib/byacc/test/yacc/code_calc.code.c similarity index 86% rename from contrib/byacc/test/code_calc.code.c rename to contrib/byacc/test/yacc/code_calc.code.c index 1c1fea101..43291db28 100644 --- a/contrib/byacc/test/code_calc.code.c +++ b/contrib/byacc/test/yacc/code_calc.code.c @@ -1,78 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 YYPURE 0 - -#line 2 "code_calc.y" -# include -# include - -int regs[26]; -int base; - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *s); -#endif - -#line 30 "code_calc.code.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 -#define YYTABLESIZE 220 -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 +#define YYENOMEM (-2) +#define YYEOF 0 #ifndef yyparse #define yyparse calc_parse @@ -155,16 +95,81 @@ extern int YYPARSE_DECL(); #endif /* yyrule */ #define YYPREFIX "calc_" +#define YYPURE 0 + +#line 2 "code_calc.y" +# include +# include + +int regs[26]; +int base; + +#ifdef YYBISON +int yylex(void); +static void yyerror(const char *s); +#endif + +#line 113 "code_calc.code.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 + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +#define YYTABLESIZE 220 +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) + extern int YYPARSE_DECL(); -extern short yylhs[]; -extern short yylen[]; -extern short yydefred[]; -extern short yydgoto[]; -extern short yysindex[]; -extern short yyrindex[]; -extern short yygindex[]; -extern short yytable[]; -extern short yycheck[]; +typedef short YYINT; +extern YYINT yylhs[]; +extern YYINT yylen[]; +extern YYINT yydefred[]; +extern YYINT yydgoto[]; +extern YYINT yysindex[]; +extern YYINT yyrindex[]; +extern YYINT yygindex[]; +extern YYINT yytable[]; +extern YYINT yycheck[]; #if YYDEBUG extern char *yyname[]; @@ -187,18 +192,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -250,7 +255,7 @@ yylex(void) } return( c ); } -#line 254 "code_calc.code.c" +#line 259 "code_calc.code.c" #if YYDEBUG #include /* needed for printf */ @@ -264,27 +269,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -334,7 +339,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -344,13 +349,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -364,7 +367,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -383,7 +386,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -404,7 +407,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -428,13 +431,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -516,7 +517,7 @@ case 18: #line 65 "code_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 520 "code_calc.code.c" +#line 521 "code_calc.code.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -534,19 +535,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -559,16 +558,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/yacc/code_calc.error b/contrib/byacc/test/yacc/code_calc.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/code_calc.output b/contrib/byacc/test/yacc/code_calc.output similarity index 100% rename from contrib/byacc/test/code_calc.output rename to contrib/byacc/test/yacc/code_calc.output diff --git a/contrib/byacc/test/code_calc.tab.c b/contrib/byacc/test/yacc/code_calc.tab.c similarity index 70% rename from contrib/byacc/test/code_calc.tab.c rename to contrib/byacc/test/yacc/code_calc.tab.c index 37a17ef4f..e72fa8421 100644 --- a/contrib/byacc/test/code_calc.tab.c +++ b/contrib/byacc/test/yacc/code_calc.tab.c @@ -1,117 +1,37 @@ - -#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_" -const short calc_lhs[] = { -1, +typedef short YYINT; +const YYINT calc_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -const short calc_len[] = { 2, +const YYINT calc_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -const short calc_defred[] = { 1, +const YYINT 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, }; -const short calc_dgoto[] = { 1, +const YYINT calc_dgoto[] = { 1, 7, 8, 9, }; -const short calc_sindex[] = { 0, +const YYINT 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, }; -const short calc_rindex[] = { 0, +const YYINT 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, }; -const short calc_gindex[] = { 0, +const YYINT calc_gindex[] = { 0, 0, 65, 0, }; -const short calc_table[] = { 6, +const YYINT 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, @@ -135,7 +55,7 @@ const short calc_table[] = { 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, }; -const short calc_check[] = { 40, +const YYINT 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, @@ -163,7 +83,7 @@ const short calc_check[] = { 40, #define YYDEBUG 0 #endif #if YYDEBUG -const char *yyname[] = { +const char *const calc_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, @@ -172,9 +92,9 @@ const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", }; -const char *yyrule[] = { +const char *const calc_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", diff --git a/contrib/byacc/test/code_calc.tab.h b/contrib/byacc/test/yacc/code_calc.tab.h similarity index 100% rename from contrib/byacc/test/code_calc.tab.h rename to contrib/byacc/test/yacc/code_calc.tab.h diff --git a/contrib/byacc/test/code_error.code.c b/contrib/byacc/test/yacc/code_error.code.c similarity index 84% rename from contrib/byacc/test/code_error.code.c rename to contrib/byacc/test/yacc/code_error.code.c index 43ce409c3..38d3e5866 100644 --- a/contrib/byacc/test/code_error.code.c +++ b/contrib/byacc/test/yacc/code_error.code.c @@ -1,70 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 YYPURE 0 - -#line 2 "code_error.y" - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *); -#endif - -#line 25 "code_error.code.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 YYERRCODE 256 -#define YYTABLESIZE 0 -#define YYFINAL 2 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 0 +#define YYENOMEM (-2) +#define YYEOF 0 #ifndef yyparse #define yyparse error_parse @@ -147,16 +95,73 @@ extern int YYPARSE_DECL(); #endif /* yyrule */ #define YYPREFIX "error_" +#define YYPURE 0 + +#line 2 "code_error.y" + +#ifdef YYBISON +int yylex(void); +static void yyerror(const char *); +#endif + +#line 108 "code_error.code.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 + +#define YYERRCODE 256 +#define YYTABLESIZE 0 +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) + extern int YYPARSE_DECL(); -extern short yylhs[]; -extern short yylen[]; -extern short yydefred[]; -extern short yydgoto[]; -extern short yysindex[]; -extern short yyrindex[]; -extern short yygindex[]; -extern short yytable[]; -extern short yycheck[]; +typedef short YYINT; +extern YYINT yylhs[]; +extern YYINT yylen[]; +extern YYINT yydefred[]; +extern YYINT yydgoto[]; +extern YYINT yysindex[]; +extern YYINT yyrindex[]; +extern YYINT yygindex[]; +extern YYINT yytable[]; +extern YYINT yycheck[]; #if YYDEBUG extern char *yyname[]; @@ -179,18 +184,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -222,7 +227,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 226 "code_error.code.c" +#line 231 "code_error.code.c" #if YYDEBUG #include /* needed for printf */ @@ -236,27 +241,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -306,7 +311,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -316,13 +321,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -336,7 +339,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -355,7 +358,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -376,7 +379,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -400,13 +403,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -445,19 +446,17 @@ YYPARSE_DECL() *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -470,16 +469,16 @@ YYPARSE_DECL() 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/yacc/code_error.error b/contrib/byacc/test/yacc/code_error.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/code_error.output b/contrib/byacc/test/yacc/code_error.output similarity index 100% rename from contrib/byacc/test/code_error.output rename to contrib/byacc/test/yacc/code_error.output diff --git a/contrib/byacc/test/yacc/code_error.tab.c b/contrib/byacc/test/yacc/code_error.tab.c new file mode 100644 index 000000000..9296aa5b1 --- /dev/null +++ b/contrib/byacc/test/yacc/code_error.tab.c @@ -0,0 +1,44 @@ +typedef short YYINT; +const YYINT error_lhs[] = { -1, + 0, +}; +const YYINT error_len[] = { 2, + 1, +}; +const YYINT error_defred[] = { 0, + 1, 0, +}; +const YYINT error_dgoto[] = { 2, +}; +const YYINT error_sindex[] = { -256, + 0, 0, +}; +const YYINT error_rindex[] = { 0, + 0, 0, +}; +const YYINT error_gindex[] = { 0, +}; +const YYINT error_table[] = { 1, +}; +const YYINT error_check[] = { 256, +}; +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#if YYDEBUG +const char *const error_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", +}; +const char *const error_rule[] = { +"$accept : S", +"S : error", + +}; +#endif diff --git a/contrib/byacc/test/yacc/code_error.tab.h b/contrib/byacc/test/yacc/code_error.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/empty.error b/contrib/byacc/test/yacc/empty.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/empty.output b/contrib/byacc/test/yacc/empty.output new file mode 100644 index 000000000..b7cf396ef --- /dev/null +++ b/contrib/byacc/test/yacc/empty.output @@ -0,0 +1,21 @@ + 0 $accept : start $end + + 1 start : + +state 0 + $accept : . start $end (0) + start : . (1) + + . reduce 1 + + start goto 1 + + +state 1 + $accept : start . $end (0) + + $end accept + + +2 terminals, 2 nonterminals +2 grammar rules, 2 states diff --git a/contrib/byacc/test/yacc/empty.tab.c b/contrib/byacc/test/yacc/empty.tab.c new file mode 100644 index 000000000..da0c4be7a --- /dev/null +++ b/contrib/byacc/test/yacc/empty.tab.c @@ -0,0 +1,503 @@ +/* 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 empty_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex empty_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror empty_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar empty_char +#endif /* yychar */ + +#ifndef yyval +#define yyval empty_val +#endif /* yyval */ + +#ifndef yylval +#define yylval empty_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug empty_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs empty_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag empty_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs empty_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen empty_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred empty_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto empty_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex empty_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex empty_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex empty_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable empty_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck empty_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname empty_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule empty_rule +#endif /* yyrule */ +#define YYPREFIX "empty_" + +#define YYPURE 0 + +#line 2 "empty.y" +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +static int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif +#line 108 "empty.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 YYERRCODE 256 +typedef short YYINT; +static const YYINT empty_lhs[] = { -1, + 0, +}; +static const YYINT empty_len[] = { 2, + 0, +}; +static const YYINT empty_defred[] = { 1, + 0, +}; +static const YYINT empty_dgoto[] = { 1, +}; +static const YYINT empty_sindex[] = { 0, + 0, +}; +static const YYINT empty_rindex[] = { 0, + 0, +}; +static const YYINT empty_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT empty_table[] = { 0, +}; +static const YYINT empty_check[] = { -1, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const empty_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", +}; +static const char *const empty_rule[] = { +"$accept : start", +"start :", + +}; +#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; + 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 13 "empty.y" + +#include + +static int +YYLEX_DECL() { + return -1; +} + +static void +YYERROR_DECL() { + printf("%s\n",s); +} +#line 244 "empty.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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) + { + } + 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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/empty.tab.h b/contrib/byacc/test/yacc/empty.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax1.error b/contrib/byacc/test/yacc/err_syntax1.error new file mode 100644 index 000000000..e3a341d4e --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax1.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./test/err_syntax1.y", syntax error + ?% { + ^ diff --git a/contrib/byacc/test/yacc/err_syntax1.output b/contrib/byacc/test/yacc/err_syntax1.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax1.tab.c b/contrib/byacc/test/yacc/err_syntax1.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax1.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax1.tab.h b/contrib/byacc/test/yacc/err_syntax1.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax10.error b/contrib/byacc/test/yacc/err_syntax10.error new file mode 100644 index 000000000..ceb876ec6 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax10.error @@ -0,0 +1,3 @@ +YACC: w - line 7 of "./test/err_syntax10.y", the type of '(' has been redeclared +YACC: w - line 7 of "./test/err_syntax10.y", the type of '*' has been redeclared +YACC: w - line 7 of "./test/err_syntax10.y", the type of '&' has been redeclared diff --git a/contrib/byacc/test/yacc/err_syntax10.output b/contrib/byacc/test/yacc/err_syntax10.output new file mode 100644 index 000000000..1b4542bde --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax10.output @@ -0,0 +1,27 @@ + 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 + + +5 terminals, 2 nonterminals +2 grammar rules, 3 states diff --git a/contrib/byacc/test/yacc/err_syntax10.tab.c b/contrib/byacc/test/yacc/err_syntax10.tab.c new file mode 100644 index 000000000..a3b450960 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax10.tab.c @@ -0,0 +1,502 @@ +/* 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 err_syntax10_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax10_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax10_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax10_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax10_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax10_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax10_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax10_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax10_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax10_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax10_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax10_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto err_syntax10_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax10_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax10_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax10_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax10_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax10_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax10_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax10_rule +#endif /* yyrule */ +#define YYPREFIX "err_syntax10_" + +#define YYPURE 0 + +#line 2 "err_syntax10.y" +int yylex(void); +static void yyerror(const char *); +#line 104 "err_syntax10.tab.c" + +/* 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 YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax10_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax10_len[] = { 2, + 1, +}; +static const YYINT err_syntax10_defred[] = { 0, + 1, 0, +}; +static const YYINT err_syntax10_dgoto[] = { 2, +}; +static const YYINT err_syntax10_sindex[] = { -256, + 0, 0, +}; +static const YYINT err_syntax10_rindex[] = { 0, + 0, 0, +}; +static const YYINT err_syntax10_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT err_syntax10_table[] = { 1, +}; +static const YYINT err_syntax10_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax10_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,"'&'",0,"'('",0,"'*'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", +}; +static const char *const err_syntax10_rule[] = { +"$accept : S", +"S : error", + +}; +#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; + 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 12 "err_syntax10.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 243 "err_syntax10.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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) + { + } + 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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/err_syntax10.tab.h b/contrib/byacc/test/yacc/err_syntax10.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax11.error b/contrib/byacc/test/yacc/err_syntax11.error new file mode 100644 index 000000000..df0aee4fb --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax11.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./test/err_syntax11.y", the precedence of '|' has been redeclared diff --git a/contrib/byacc/test/yacc/err_syntax11.output b/contrib/byacc/test/yacc/err_syntax11.output new file mode 100644 index 000000000..a71ff2a40 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax11.output @@ -0,0 +1,27 @@ + 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 + + +3 terminals, 2 nonterminals +2 grammar rules, 3 states diff --git a/contrib/byacc/test/yacc/err_syntax11.tab.c b/contrib/byacc/test/yacc/err_syntax11.tab.c new file mode 100644 index 000000000..ebb065f45 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax11.tab.c @@ -0,0 +1,508 @@ +/* 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 err_syntax11_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax11_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax11_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax11_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax11_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax11_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax11_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax11_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax11_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax11_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax11_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax11_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto err_syntax11_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax11_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax11_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax11_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax11_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax11_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax11_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax11_rule +#endif /* yyrule */ +#define YYPREFIX "err_syntax11_" + +#define YYPURE 0 + +#line 2 "err_syntax11.y" +int yylex(void); +static void yyerror(const char *); +#line 104 "err_syntax11.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 YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax11_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax11_len[] = { 2, + 1, +}; +static const YYINT err_syntax11_defred[] = { 0, + 1, 0, +}; +static const YYINT err_syntax11_dgoto[] = { 2, +}; +static const YYINT err_syntax11_sindex[] = { -256, + 0, 0, +}; +static const YYINT err_syntax11_rindex[] = { 0, + 0, 0, +}; +static const YYINT err_syntax11_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT err_syntax11_table[] = { 1, +}; +static const YYINT err_syntax11_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax11_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", +}; +static const char *const err_syntax11_rule[] = { +"$accept : S", +"S : error", + +}; +#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; + 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 12 "err_syntax11.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 249 "err_syntax11.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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) + { + } + 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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/err_syntax11.tab.h b/contrib/byacc/test/yacc/err_syntax11.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax12.error b/contrib/byacc/test/yacc/err_syntax12.error new file mode 100644 index 000000000..9399e82e1 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax12.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./test/err_syntax12.y", the value of text has been redeclared diff --git a/contrib/byacc/test/yacc/err_syntax12.output b/contrib/byacc/test/yacc/err_syntax12.output new file mode 100644 index 000000000..a71ff2a40 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax12.output @@ -0,0 +1,27 @@ + 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 + + +3 terminals, 2 nonterminals +2 grammar rules, 3 states diff --git a/contrib/byacc/test/yacc/err_syntax12.tab.c b/contrib/byacc/test/yacc/err_syntax12.tab.c new file mode 100644 index 000000000..784a45ffe --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax12.tab.c @@ -0,0 +1,514 @@ +/* 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 err_syntax12_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax12_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax12_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax12_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax12_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax12_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax12_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax12_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax12_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax12_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax12_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax12_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto err_syntax12_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax12_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax12_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax12_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax12_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax12_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax12_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax12_rule +#endif /* yyrule */ +#define YYPREFIX "err_syntax12_" + +#define YYPURE 0 + +#line 2 "err_syntax12.y" +int yylex(void); +static void yyerror(const char *); +#line 104 "err_syntax12.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 text 456 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax12_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax12_len[] = { 2, + 1, +}; +static const YYINT err_syntax12_defred[] = { 0, + 1, 0, +}; +static const YYINT err_syntax12_dgoto[] = { 2, +}; +static const YYINT err_syntax12_sindex[] = { -256, + 0, 0, +}; +static const YYINT err_syntax12_rindex[] = { 0, + 0, 0, +}; +static const YYINT err_syntax12_gindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT err_syntax12_table[] = { 1, +}; +static const YYINT err_syntax12_check[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 456 +#define YYUNDFTOKEN 459 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax12_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"text",0,0,"illegal-symbol", +}; +static const char *const err_syntax12_rule[] = { +"$accept : S", +"S : error", + +}; +#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; + 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 12 "err_syntax12.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 255 "err_syntax12.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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) + { + } + 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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/err_syntax12.tab.h b/contrib/byacc/test/yacc/err_syntax12.tab.h new file mode 100644 index 000000000..c273c0874 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax12.tab.h @@ -0,0 +1 @@ +#define text 456 diff --git a/contrib/byacc/test/yacc/err_syntax13.error b/contrib/byacc/test/yacc/err_syntax13.error new file mode 100644 index 000000000..dd062569c --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax13.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./test/err_syntax13.y", the start symbol text is a token diff --git a/contrib/byacc/test/yacc/err_syntax13.output b/contrib/byacc/test/yacc/err_syntax13.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax13.tab.c b/contrib/byacc/test/yacc/err_syntax13.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax13.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax13.tab.h b/contrib/byacc/test/yacc/err_syntax13.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax14.error b/contrib/byacc/test/yacc/err_syntax14.error new file mode 100644 index 000000000..787a21760 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax14.error @@ -0,0 +1,2 @@ +YACC: w - line 7 of "./test/err_syntax14.y", the start symbol has been redeclared +YACC: e - the start symbol text2 is undefined diff --git a/contrib/byacc/test/yacc/err_syntax14.output b/contrib/byacc/test/yacc/err_syntax14.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax14.tab.c b/contrib/byacc/test/yacc/err_syntax14.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax14.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax14.tab.h b/contrib/byacc/test/yacc/err_syntax14.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax15.error b/contrib/byacc/test/yacc/err_syntax15.error new file mode 100644 index 000000000..63600f1bd --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax15.error @@ -0,0 +1 @@ +YACC: e - line 9 of "./test/err_syntax15.y", no grammar has been specified diff --git a/contrib/byacc/test/yacc/err_syntax15.output b/contrib/byacc/test/yacc/err_syntax15.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax15.tab.c b/contrib/byacc/test/yacc/err_syntax15.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax15.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax15.tab.h b/contrib/byacc/test/yacc/err_syntax15.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax16.error b/contrib/byacc/test/yacc/err_syntax16.error new file mode 100644 index 000000000..b8dd094b9 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax16.error @@ -0,0 +1 @@ +YACC: e - line 14 of "./test/err_syntax16.y", a token appears on the lhs of a production diff --git a/contrib/byacc/test/yacc/err_syntax16.output b/contrib/byacc/test/yacc/err_syntax16.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax16.tab.c b/contrib/byacc/test/yacc/err_syntax16.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax16.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax16.tab.h b/contrib/byacc/test/yacc/err_syntax16.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax17.error b/contrib/byacc/test/yacc/err_syntax17.error new file mode 100644 index 000000000..24032f613 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax17.error @@ -0,0 +1,3 @@ +YACC: e - line 8 of "./test/err_syntax17.y", unterminated action +S: { error + ^ diff --git a/contrib/byacc/test/yacc/err_syntax17.output b/contrib/byacc/test/yacc/err_syntax17.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax17.tab.c b/contrib/byacc/test/yacc/err_syntax17.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax17.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax17.tab.h b/contrib/byacc/test/yacc/err_syntax17.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax18.error b/contrib/byacc/test/yacc/err_syntax18.error new file mode 100644 index 000000000..305b4cf45 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax18.error @@ -0,0 +1 @@ +YACC: w - line 9 of "./test/err_syntax18.y", $4 references beyond the end of the current rule diff --git a/contrib/byacc/test/yacc/err_syntax18.output b/contrib/byacc/test/yacc/err_syntax18.output new file mode 100644 index 000000000..09ed7d4c7 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax18.output @@ -0,0 +1,43 @@ + 0 $accept : expr $end + + 1 expr : '(' expr ')' + +state 0 + $accept : . expr $end (0) + + '(' shift 1 + . error + + expr goto 2 + + +state 1 + expr : '(' . expr ')' (1) + + '(' shift 1 + . error + + expr goto 3 + + +state 2 + $accept : expr . $end (0) + + $end accept + + +state 3 + expr : '(' expr . ')' (1) + + ')' shift 4 + . error + + +state 4 + expr : '(' expr ')' . (1) + + . reduce 1 + + +4 terminals, 2 nonterminals +2 grammar rules, 5 states diff --git a/contrib/byacc/test/yacc/err_syntax18.tab.c b/contrib/byacc/test/yacc/err_syntax18.tab.c new file mode 100644 index 000000000..fb7b06c40 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax18.tab.c @@ -0,0 +1,515 @@ +/* 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 err_syntax18_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax18_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax18_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax18_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax18_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax18_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax18_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax18_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax18_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax18_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax18_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax18_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto err_syntax18_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax18_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax18_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax18_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax18_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax18_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax18_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax18_rule +#endif /* yyrule */ +#define YYPREFIX "err_syntax18_" + +#define YYPURE 0 + +#line 2 "err_syntax18.y" +int yylex(void); +static void yyerror(const char *); +#line 104 "err_syntax18.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 YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax18_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax18_len[] = { 2, + 3, +}; +static const YYINT err_syntax18_defred[] = { 0, + 0, 0, 0, 1, +}; +static const YYINT err_syntax18_dgoto[] = { 2, +}; +static const YYINT err_syntax18_sindex[] = { -40, + -40, 0, -39, 0, +}; +static const YYINT err_syntax18_rindex[] = { 0, + 0, 0, 0, 0, +}; +static const YYINT err_syntax18_gindex[] = { 2, +}; +#define YYTABLESIZE 3 +static const YYINT err_syntax18_table[] = { 1, + 0, 4, 3, +}; +static const YYINT err_syntax18_check[] = { 40, + -1, 41, 1, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax18_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", +}; +static const char *const err_syntax18_rule[] = { +"$accept : expr", +"expr : '(' expr ')'", + +}; +#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; + 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 13 "err_syntax18.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 251 "err_syntax18.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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 1: +#line 9 "err_syntax18.y" + { yyval = yystack.l_mark[1]; } +break; +#line 457 "err_syntax18.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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/err_syntax18.tab.h b/contrib/byacc/test/yacc/err_syntax18.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax19.error b/contrib/byacc/test/yacc/err_syntax19.error new file mode 100644 index 000000000..895c8fe16 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax19.error @@ -0,0 +1,3 @@ +YACC: e - line 9 of "./test/err_syntax19.y", illegal $-name + { $$ = $; } + ^ diff --git a/contrib/byacc/test/yacc/err_syntax19.output b/contrib/byacc/test/yacc/err_syntax19.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax19.tab.c b/contrib/byacc/test/yacc/err_syntax19.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax19.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax19.tab.h b/contrib/byacc/test/yacc/err_syntax19.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax2.error b/contrib/byacc/test/yacc/err_syntax2.error new file mode 100644 index 000000000..fefda9fcf --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax2.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./test/err_syntax2.y", unmatched /* +%{ /* + ^ diff --git a/contrib/byacc/test/yacc/err_syntax2.output b/contrib/byacc/test/yacc/err_syntax2.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax2.tab.c b/contrib/byacc/test/yacc/err_syntax2.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax2.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax2.tab.h b/contrib/byacc/test/yacc/err_syntax2.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax20.error b/contrib/byacc/test/yacc/err_syntax20.error new file mode 100644 index 000000000..76dac8152 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax20.error @@ -0,0 +1 @@ +YACC: w - the symbol recur is undefined diff --git a/contrib/byacc/test/yacc/err_syntax20.output b/contrib/byacc/test/yacc/err_syntax20.output new file mode 100644 index 000000000..cfe62800c --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax20.output @@ -0,0 +1,41 @@ + 0 $accept : expr $end + + 1 expr : '(' recur ')' + +state 0 + $accept : . expr $end (0) + + '(' shift 1 + . error + + expr goto 2 + + +state 1 + expr : '(' . recur ')' (1) + + recur shift 3 + . error + + +state 2 + $accept : expr . $end (0) + + $end accept + + +state 3 + expr : '(' recur . ')' (1) + + ')' shift 4 + . error + + +state 4 + expr : '(' recur ')' . (1) + + . reduce 1 + + +5 terminals, 2 nonterminals +2 grammar rules, 5 states diff --git a/contrib/byacc/test/yacc/err_syntax20.tab.c b/contrib/byacc/test/yacc/err_syntax20.tab.c new file mode 100644 index 000000000..85ea1ba90 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax20.tab.c @@ -0,0 +1,511 @@ +/* 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 err_syntax20_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex err_syntax20_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror err_syntax20_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar err_syntax20_char +#endif /* yychar */ + +#ifndef yyval +#define yyval err_syntax20_val +#endif /* yyval */ + +#ifndef yylval +#define yylval err_syntax20_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug err_syntax20_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs err_syntax20_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag err_syntax20_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs err_syntax20_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen err_syntax20_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred err_syntax20_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto err_syntax20_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex err_syntax20_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex err_syntax20_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex err_syntax20_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable err_syntax20_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck err_syntax20_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname err_syntax20_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule err_syntax20_rule +#endif /* yyrule */ +#define YYPREFIX "err_syntax20_" + +#define YYPURE 0 + +#line 2 "err_syntax20.y" +int yylex(void); +static void yyerror(const char *); +#line 104 "err_syntax20.tab.c" + +/* 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 recur 257 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT err_syntax20_lhs[] = { -1, + 0, +}; +static const YYINT err_syntax20_len[] = { 2, + 3, +}; +static const YYINT err_syntax20_defred[] = { 0, + 0, 0, 0, 1, +}; +static const YYINT err_syntax20_dgoto[] = { 2, +}; +static const YYINT err_syntax20_sindex[] = { -40, + -256, 0, -39, 0, +}; +static const YYINT err_syntax20_rindex[] = { 0, + 0, 0, 0, 0, +}; +static const YYINT err_syntax20_gindex[] = { 0, +}; +#define YYTABLESIZE 2 +static const YYINT err_syntax20_table[] = { 1, + 3, 4, +}; +static const YYINT err_syntax20_check[] = { 40, + 257, 41, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 257 +#define YYUNDFTOKEN 260 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const err_syntax20_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"recur",0,0, +"illegal-symbol", +}; +static const char *const err_syntax20_rule[] = { +"$accept : expr", +"expr : '(' recur ')'", + +}; +#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; + 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 16 "err_syntax20.y" + +#include + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 247 "err_syntax20.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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 1: +#line 12 "err_syntax20.y" + { yystack.l_mark[-1].rechk = 3; } +break; +#line 453 "err_syntax20.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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/err_syntax20.tab.h b/contrib/byacc/test/yacc/err_syntax20.tab.h new file mode 100644 index 000000000..60dabd611 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax20.tab.h @@ -0,0 +1 @@ +#define recur 257 diff --git a/contrib/byacc/test/yacc/err_syntax21.error b/contrib/byacc/test/yacc/err_syntax21.error new file mode 100644 index 000000000..162d82d0c --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax21.error @@ -0,0 +1 @@ +YACC: e - line 12 of "./test/err_syntax21.y", $0 is untyped diff --git a/contrib/byacc/test/yacc/err_syntax21.output b/contrib/byacc/test/yacc/err_syntax21.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax21.tab.c b/contrib/byacc/test/yacc/err_syntax21.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax21.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax21.tab.h b/contrib/byacc/test/yacc/err_syntax21.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax22.error b/contrib/byacc/test/yacc/err_syntax22.error new file mode 100644 index 000000000..9c71619c4 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax22.error @@ -0,0 +1 @@ +YACC: e - line 17 of "./test/err_syntax22.y", $2 (recur) is untyped diff --git a/contrib/byacc/test/yacc/err_syntax22.output b/contrib/byacc/test/yacc/err_syntax22.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax22.tab.c b/contrib/byacc/test/yacc/err_syntax22.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax22.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax22.tab.h b/contrib/byacc/test/yacc/err_syntax22.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax23.error b/contrib/byacc/test/yacc/err_syntax23.error new file mode 100644 index 000000000..bcde6e7fa --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax23.error @@ -0,0 +1 @@ +YACC: e - line 18 of "./test/err_syntax23.y", $$ is untyped diff --git a/contrib/byacc/test/yacc/err_syntax23.output b/contrib/byacc/test/yacc/err_syntax23.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax23.tab.c b/contrib/byacc/test/yacc/err_syntax23.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax23.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax23.tab.h b/contrib/byacc/test/yacc/err_syntax23.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax24.error b/contrib/byacc/test/yacc/err_syntax24.error new file mode 100644 index 000000000..bdd3aeda0 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax24.error @@ -0,0 +1,2 @@ +YACC: w - line 21 of "./test/err_syntax24.y", the default action assigns an undefined value to $$ +YACC: e - line 22 of "./test/err_syntax24.y", $$ is untyped diff --git a/contrib/byacc/test/yacc/err_syntax24.output b/contrib/byacc/test/yacc/err_syntax24.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax24.tab.c b/contrib/byacc/test/yacc/err_syntax24.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax24.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax24.tab.h b/contrib/byacc/test/yacc/err_syntax24.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax25.error b/contrib/byacc/test/yacc/err_syntax25.error new file mode 100644 index 000000000..ea45a7031 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax25.error @@ -0,0 +1,3 @@ +YACC: e - line 11 of "./test/err_syntax25.y", too many %union declarations +%union { +^ diff --git a/contrib/byacc/test/yacc/err_syntax25.output b/contrib/byacc/test/yacc/err_syntax25.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax25.tab.c b/contrib/byacc/test/yacc/err_syntax25.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax25.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax25.tab.h b/contrib/byacc/test/yacc/err_syntax25.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax26.error b/contrib/byacc/test/yacc/err_syntax26.error new file mode 100644 index 000000000..cddd5741b --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax26.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./test/err_syntax26.y", unexpected end-of-file diff --git a/contrib/byacc/test/yacc/err_syntax26.output b/contrib/byacc/test/yacc/err_syntax26.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax26.tab.c b/contrib/byacc/test/yacc/err_syntax26.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax26.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax26.tab.h b/contrib/byacc/test/yacc/err_syntax26.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax27.error b/contrib/byacc/test/yacc/err_syntax27.error new file mode 100644 index 000000000..4737f99b9 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax27.error @@ -0,0 +1 @@ +YACC: e - line 3 of "./test/err_syntax27.y", missing '}' diff --git a/contrib/byacc/test/yacc/err_syntax27.output b/contrib/byacc/test/yacc/err_syntax27.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax27.tab.c b/contrib/byacc/test/yacc/err_syntax27.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax27.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax27.tab.h b/contrib/byacc/test/yacc/err_syntax27.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax3.error b/contrib/byacc/test/yacc/err_syntax3.error new file mode 100644 index 000000000..6926214f5 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax3.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax3.y", unterminated string +%token '(' '*' '& + ^ diff --git a/contrib/byacc/test/yacc/err_syntax3.output b/contrib/byacc/test/yacc/err_syntax3.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax3.tab.c b/contrib/byacc/test/yacc/err_syntax3.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax3.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax3.tab.h b/contrib/byacc/test/yacc/err_syntax3.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax4.error b/contrib/byacc/test/yacc/err_syntax4.error new file mode 100644 index 000000000..72b683ee7 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax4.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./test/err_syntax4.y", unmatched %{ +%{ +^ diff --git a/contrib/byacc/test/yacc/err_syntax4.output b/contrib/byacc/test/yacc/err_syntax4.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax4.tab.c b/contrib/byacc/test/yacc/err_syntax4.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax4.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax4.tab.h b/contrib/byacc/test/yacc/err_syntax4.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax5.error b/contrib/byacc/test/yacc/err_syntax5.error new file mode 100644 index 000000000..fd3bf0df6 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax5.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax5.y", unterminated %union declaration +%union { +^ diff --git a/contrib/byacc/test/yacc/err_syntax5.output b/contrib/byacc/test/yacc/err_syntax5.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax5.tab.c b/contrib/byacc/test/yacc/err_syntax5.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax5.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax5.tab.h b/contrib/byacc/test/yacc/err_syntax5.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax6.error b/contrib/byacc/test/yacc/err_syntax6.error new file mode 100644 index 000000000..ae83bd2a3 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax6.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax6.y", illegal tag +%token '\777' + ^ diff --git a/contrib/byacc/test/yacc/err_syntax7.output b/contrib/byacc/test/yacc/err_syntax7.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax7.tab.c b/contrib/byacc/test/yacc/err_syntax7.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax7.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax7.tab.h b/contrib/byacc/test/yacc/err_syntax7.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax7a.error b/contrib/byacc/test/yacc/err_syntax7a.error new file mode 100644 index 000000000..f6adba64d --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax7a.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax7a.y", illegal character +%token '\xfff' + ^ diff --git a/contrib/byacc/test/yacc/err_syntax7a.output b/contrib/byacc/test/yacc/err_syntax7a.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax7a.tab.c b/contrib/byacc/test/yacc/err_syntax7a.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax7a.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax7a.tab.h b/contrib/byacc/test/yacc/err_syntax7a.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax7b.error b/contrib/byacc/test/yacc/err_syntax7b.error new file mode 100644 index 000000000..f3e512fd1 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax7b.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./test/err_syntax7b.y", illegal character +%token '\x.' + ^ diff --git a/contrib/byacc/test/yacc/err_syntax7b.output b/contrib/byacc/test/yacc/err_syntax7b.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax7b.tab.c b/contrib/byacc/test/yacc/err_syntax7b.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax7b.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax7b.tab.h b/contrib/byacc/test/yacc/err_syntax7b.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax8.error b/contrib/byacc/test/yacc/err_syntax8.error new file mode 100644 index 000000000..53a3a328d --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax8.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./test/err_syntax8.y", illegal use of reserved symbol . diff --git a/contrib/byacc/test/yacc/err_syntax8.output b/contrib/byacc/test/yacc/err_syntax8.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax8.tab.c b/contrib/byacc/test/yacc/err_syntax8.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax8.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax8.tab.h b/contrib/byacc/test/yacc/err_syntax8.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax8a.error b/contrib/byacc/test/yacc/err_syntax8a.error new file mode 100644 index 000000000..313555163 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax8a.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./test/err_syntax8a.y", illegal use of reserved symbol $$123 diff --git a/contrib/byacc/test/yacc/err_syntax8a.output b/contrib/byacc/test/yacc/err_syntax8a.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax8a.tab.c b/contrib/byacc/test/yacc/err_syntax8a.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax8a.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax8a.tab.h b/contrib/byacc/test/yacc/err_syntax8a.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax9.error b/contrib/byacc/test/yacc/err_syntax9.error new file mode 100644 index 000000000..43696bd1f --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax9.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./test/err_syntax9.y", the start symbol text cannot be declared to be a token diff --git a/contrib/byacc/test/yacc/err_syntax9.output b/contrib/byacc/test/yacc/err_syntax9.output new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/err_syntax9.tab.c b/contrib/byacc/test/yacc/err_syntax9.tab.c new file mode 100644 index 000000000..6c35f2332 --- /dev/null +++ b/contrib/byacc/test/yacc/err_syntax9.tab.c @@ -0,0 +1,15 @@ +/* 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/contrib/byacc/test/yacc/err_syntax9.tab.h b/contrib/byacc/test/yacc/err_syntax9.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/error.error b/contrib/byacc/test/yacc/error.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/error.output b/contrib/byacc/test/yacc/error.output similarity index 100% rename from contrib/byacc/test/error.output rename to contrib/byacc/test/yacc/error.output diff --git a/contrib/byacc/test/error.tab.c b/contrib/byacc/test/yacc/error.tab.c similarity index 77% rename from contrib/byacc/test/error.tab.c rename to contrib/byacc/test/yacc/error.tab.c index 0cb6fb3fa..e7aa39508 100644 --- a/contrib/byacc/test/error.tab.c +++ b/contrib/byacc/test/yacc/error.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 error_parse @@ -98,10 +100,12 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #line 2 "error.y" int yylex(void); static void yyerror(const char *); -#line 102 "error.tab.c" +#line 104 "error.tab.c" -#ifndef YYSTYPE +#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 */ @@ -136,41 +140,50 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); #define YYERRCODE 256 -static const short error_lhs[] = { -1, +typedef short YYINT; +static const YYINT error_lhs[] = { -1, 0, }; -static const short error_len[] = { 2, +static const YYINT error_len[] = { 2, 1, }; -static const short error_defred[] = { 0, +static const YYINT error_defred[] = { 0, 1, 0, }; -static const short error_dgoto[] = { 2, +static const YYINT error_dgoto[] = { 2, }; -static const short error_sindex[] = { -256, +static const YYINT error_sindex[] = { -256, 0, 0, }; -static const short error_rindex[] = { 0, +static const YYINT error_rindex[] = { 0, 0, 0, }; -static const short error_gindex[] = { 0, +static const YYINT error_gindex[] = { 0, }; #define YYTABLESIZE 0 -static const short error_table[] = { 1, +static const YYINT error_table[] = { 1, }; -static const short error_check[] = { 256, +static const YYINT error_check[] = { 256, }; #define YYFINAL 2 #ifndef YYDEBUG #define YYDEBUG 0 #endif -#define YYMAXTOKEN 0 +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { - -"end-of-file", +static const char *const error_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const error_rule[] = { "$accept : S", "S : error", @@ -193,18 +206,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -232,7 +245,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 236 "error.tab.c" +#line 249 "error.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -246,27 +259,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -316,7 +329,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -326,13 +339,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -346,7 +357,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -365,7 +376,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -386,7 +397,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -410,13 +421,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -455,19 +464,17 @@ YYPARSE_DECL() *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -480,16 +487,16 @@ YYPARSE_DECL() 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/yacc/error.tab.h b/contrib/byacc/test/yacc/error.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/grammar.dot b/contrib/byacc/test/yacc/grammar.dot new file mode 100644 index 000000000..1988e12dd --- /dev/null +++ b/contrib/byacc/test/yacc/grammar.dot @@ -0,0 +1,906 @@ +digraph test-grammar { + edge [fontsize=10]; + node [shape=box,fontsize=10]; + orientation=landscape; + rankdir=LR; + /* + margin=0.2; + page="8.27,11.69"; // for A4 printing + ratio=auto; + */ + + q0 [label="0:\l $accept -> . program $end\l program -> . { $end }\l program -> . translation_unit\l translation_unit -> . external_declaration\l translation_unit -> . translation_unit external_declaration\l external_declaration -> . declaration\l external_declaration -> . function_definition\l external_declaration -> . ';'\l external_declaration -> . linkage_specification\l external_declaration -> . T_ASM T_ASMARG ';'\l external_declaration -> . error T_MATCHRBRACE\l external_declaration -> . error ';'\l linkage_specification -> . T_EXTERN T_STRING_LITERAL braces\l linkage_specification -> . T_EXTERN T_STRING_LITERAL declaration\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> . decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l function_definition -> . declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q1 [label="1:\l external_declaration -> error . T_MATCHRBRACE\l external_declaration -> error . ';'\l"]; + q2 [label="2:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> '(' . declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q3 [label="3:\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l pointer -> '*' . opt_type_qualifiers\l pointer -> '*' . opt_type_qualifiers pointer\l opt_type_qualifiers -> . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l opt_type_qualifiers -> . type_qualifier_list\l type_qualifier_list -> . type_qualifier\l type_qualifier_list -> . type_qualifier_list type_qualifier\l"]; + q4 [label="4:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l identifier_or_ref -> '&' . any_id\l"]; + q5 [label="5:\l any_id -> T_IDENTIFIER . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q6 [label="6:\l type_specifier -> T_TYPEDEF_NAME . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l any_id -> T_TYPEDEF_NAME . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q7 [label="7:\l type_qualifier -> T_DEFINE_NAME . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q8 [label="8:\l storage_class -> T_AUTO . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q9 [label="9:\l linkage_specification -> T_EXTERN . T_STRING_LITERAL braces\l linkage_specification -> T_EXTERN . T_STRING_LITERAL declaration\l storage_class -> T_EXTERN . { ';' T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q10 [label="10:\l storage_class -> T_REGISTER . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q11 [label="11:\l storage_class -> T_STATIC . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q12 [label="12:\l any_typedef -> T_TYPEDEF . { T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q13 [label="13:\l storage_class -> T_INLINE . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q14 [label="14:\l any_typedef -> T_EXTENSION . T_TYPEDEF\l storage_class -> T_EXTENSION . { ';' T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q15 [label="15:\l type_specifier -> T_CHAR . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q16 [label="16:\l type_specifier -> T_DOUBLE . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q17 [label="17:\l type_specifier -> T_FLOAT . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q18 [label="18:\l type_specifier -> T_INT . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q19 [label="19:\l type_specifier -> T_VOID . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q20 [label="20:\l type_specifier -> T_LONG . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q21 [label="21:\l type_specifier -> T_SHORT . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q22 [label="22:\l type_specifier -> T_SIGNED . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q23 [label="23:\l type_specifier -> T_UNSIGNED . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q24 [label="24:\l enumeration -> T_ENUM . { T_LBRACE T_TYPEDEF_NAME T_IDENTIFIER }\l"]; + q25 [label="25:\l struct_or_union -> T_STRUCT . { T_LBRACE T_TYPEDEF_NAME T_IDENTIFIER }\l"]; + q26 [label="26:\l struct_or_union -> T_UNION . { T_LBRACE T_TYPEDEF_NAME T_IDENTIFIER }\l"]; + q27 [label="27:\l type_specifier -> T_Bool . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q28 [label="28:\l type_specifier -> T_Complex . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q29 [label="29:\l type_specifier -> T_Imaginary . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q30 [label="30:\l type_qualifier -> T_TYPE_QUALIFIER . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q31 [label="31:\l external_declaration -> T_ASM . T_ASMARG ';'\l"]; + q32 [label="32:\l external_declaration -> ';' . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q33 [label="33:\l $accept -> program . $end\l"]; + q34 [label="34:\l declaration -> decl_specifiers . ';'\l declaration -> decl_specifiers . init_declarator_list ';'\l function_definition -> decl_specifiers . declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l init_declarator_list -> . init_declarator\l init_declarator_list -> . init_declarator_list ',' init_declarator\l init_declarator -> . declarator\l init_declarator -> . declarator '=' $$5 T_INITIALIZER\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q35 [label="35:\l decl_specifiers -> decl_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q36 [label="36:\l decl_specifier -> storage_class . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q37 [label="37:\l decl_specifier -> type_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q38 [label="38:\l decl_specifier -> type_qualifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q39 [label="39:\l type_specifier -> struct_or_union_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q40 [label="40:\l type_specifier -> enum_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q41 [label="41:\l $$4 -> . { T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l function_definition -> declarator . $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE\l"]; + q42 [label="42:\l declarator -> direct_declarator . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l direct_declarator -> direct_declarator . T_BRACKETS\l direct_declarator -> direct_declarator . '(' parameter_type_list ')'\l direct_declarator -> direct_declarator . '(' opt_identifier_list ')'\l"]; + q43 [label="43:\l braces -> . T_LBRACE T_MATCHRBRACE\l struct_or_union_specifier -> struct_or_union . any_id braces\l struct_or_union_specifier -> struct_or_union . braces\l struct_or_union_specifier -> struct_or_union . any_id\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l"]; + q44 [label="44:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> pointer . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q45 [label="45:\l identifier_or_ref -> any_id . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q46 [label="46:\l direct_declarator -> identifier_or_ref . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q47 [label="47:\l braces -> . T_LBRACE T_MATCHRBRACE\l enum_specifier -> enumeration . any_id braces\l enum_specifier -> enumeration . braces\l enum_specifier -> enumeration . any_id\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l"]; + q48 [label="48:\l program -> translation_unit . { $end }\l translation_unit -> translation_unit . external_declaration\l external_declaration -> . declaration\l external_declaration -> . function_definition\l external_declaration -> . ';'\l external_declaration -> . linkage_specification\l external_declaration -> . T_ASM T_ASMARG ';'\l external_declaration -> . error T_MATCHRBRACE\l external_declaration -> . error ';'\l linkage_specification -> . T_EXTERN T_STRING_LITERAL braces\l linkage_specification -> . T_EXTERN T_STRING_LITERAL declaration\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> . decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l function_definition -> . declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q49 [label="49:\l translation_unit -> external_declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q50 [label="50:\l external_declaration -> declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q51 [label="51:\l external_declaration -> function_definition . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q52 [label="52:\l external_declaration -> linkage_specification . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q53 [label="53:\l declaration -> any_typedef . decl_specifiers $$1 opt_declarator_list ';'\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q54 [label="54:\l external_declaration -> error T_MATCHRBRACE . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q55 [label="55:\l external_declaration -> error ';' . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q56 [label="56:\l any_id -> T_TYPEDEF_NAME . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q57 [label="57:\l direct_declarator -> '(' declarator . ')'\l"]; + q58 [label="58:\l type_qualifier_list -> type_qualifier . { ')' ',' T_BRACKETS T_TYPE_QUALIFIER T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q59 [label="59:\l pointer -> . '*' opt_type_qualifiers\l pointer -> '*' opt_type_qualifiers . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '(' }\l pointer -> . '*' opt_type_qualifiers pointer\l pointer -> '*' opt_type_qualifiers . pointer\l"]; + q60 [label="60:\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l opt_type_qualifiers -> type_qualifier_list . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l type_qualifier_list -> type_qualifier_list . type_qualifier\l"]; + q61 [label="61:\l identifier_or_ref -> '&' any_id . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q62 [label="62:\l braces -> . T_LBRACE T_MATCHRBRACE\l linkage_specification -> T_EXTERN T_STRING_LITERAL . braces\l linkage_specification -> T_EXTERN T_STRING_LITERAL . declaration\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q63 [label="63:\l any_typedef -> T_EXTENSION T_TYPEDEF . { T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q64 [label="64:\l external_declaration -> T_ASM T_ASMARG . ';'\l"]; + q65 [label="65:\l storage_class -> T_EXTERN . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q66 [label="66:\l storage_class -> T_EXTENSION . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q67 [label="67:\l declaration -> decl_specifiers ';' . { ';' T_ASM T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q68 [label="68:\l decl_specifiers -> decl_specifiers decl_specifier . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q69 [label="69:\l declaration -> decl_specifiers init_declarator_list . ';'\l init_declarator_list -> init_declarator_list . ',' init_declarator\l"]; + q70 [label="70:\l init_declarator_list -> init_declarator . { ',' ';' }\l"]; + q71 [label="71:\l $$2 -> . { T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l function_definition -> decl_specifiers declarator . $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l init_declarator -> declarator . { ',' ';' }\l init_declarator -> declarator . '=' $$5 T_INITIALIZER\l"]; + q72 [label="72:\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> declarator $$4 . opt_declaration_list T_LBRACE T_MATCHRBRACE\l opt_declaration_list -> . { T_LBRACE }\l opt_declaration_list -> . T_VA_DCL\l opt_declaration_list -> . declaration_list\l declaration_list -> . declaration\l declaration_list -> . declaration_list declaration\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q73 [label="73:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l direct_declarator -> direct_declarator '(' . parameter_type_list ')'\l direct_declarator -> direct_declarator '(' . opt_identifier_list ')'\l parameter_type_list -> . parameter_list\l parameter_type_list -> . parameter_list ',' T_ELLIPSIS\l parameter_list -> . parameter_declaration\l parameter_list -> . parameter_list ',' parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l opt_identifier_list -> . { ')' }\l opt_identifier_list -> . identifier_list\l identifier_list -> . any_id\l identifier_list -> . identifier_list ',' any_id\l"]; + q74 [label="74:\l direct_declarator -> direct_declarator T_BRACKETS . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q75 [label="75:\l braces -> T_LBRACE . T_MATCHRBRACE\l"]; + q76 [label="76:\l braces -> . T_LBRACE T_MATCHRBRACE\l struct_or_union_specifier -> struct_or_union any_id . braces\l struct_or_union_specifier -> struct_or_union any_id . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q77 [label="77:\l struct_or_union_specifier -> struct_or_union braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q78 [label="78:\l declarator -> pointer direct_declarator . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l direct_declarator -> direct_declarator . T_BRACKETS\l direct_declarator -> direct_declarator . '(' parameter_type_list ')'\l direct_declarator -> direct_declarator . '(' opt_identifier_list ')'\l"]; + q79 [label="79:\l braces -> . T_LBRACE T_MATCHRBRACE\l enum_specifier -> enumeration any_id . braces\l enum_specifier -> enumeration any_id . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q80 [label="80:\l enum_specifier -> enumeration braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q81 [label="81:\l translation_unit -> translation_unit external_declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q82 [label="82:\l type_specifier -> T_TYPEDEF_NAME . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q83 [label="83:\l $$1 -> . { ';' T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l declaration -> any_typedef decl_specifiers . $$1 opt_declarator_list ';'\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q84 [label="84:\l direct_declarator -> '(' declarator ')' . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q85 [label="85:\l pointer -> '*' opt_type_qualifiers pointer . { ')' ',' T_BRACKETS T_TYPEDEF_NAME T_IDENTIFIER '&' '(' }\l"]; + q86 [label="86:\l type_qualifier_list -> type_qualifier_list type_qualifier . { ')' ',' T_BRACKETS T_TYPE_QUALIFIER T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q87 [label="87:\l declaration -> decl_specifiers . ';'\l declaration -> decl_specifiers . init_declarator_list ';'\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l init_declarator_list -> . init_declarator\l init_declarator_list -> . init_declarator_list ',' init_declarator\l init_declarator -> . declarator\l init_declarator -> . declarator '=' $$5 T_INITIALIZER\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q88 [label="88:\l linkage_specification -> T_EXTERN T_STRING_LITERAL declaration . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q89 [label="89:\l linkage_specification -> T_EXTERN T_STRING_LITERAL braces . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q90 [label="90:\l external_declaration -> T_ASM T_ASMARG ';' . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q91 [label="91:\l declaration -> decl_specifiers init_declarator_list ';' . { ';' T_ASM T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q92 [label="92:\l init_declarator_list -> init_declarator_list ',' . init_declarator\l init_declarator -> . declarator\l init_declarator -> . declarator '=' $$5 T_INITIALIZER\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q93 [label="93:\l $$5 -> . { T_INITIALIZER }\l init_declarator -> declarator '=' . $$5 T_INITIALIZER\l"]; + q94 [label="94:\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l function_definition -> decl_specifiers declarator $$2 . opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE\l opt_declaration_list -> . { T_LBRACE }\l opt_declaration_list -> . T_VA_DCL\l opt_declaration_list -> . declaration_list\l declaration_list -> . declaration\l declaration_list -> . declaration_list declaration\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q95 [label="95:\l opt_declaration_list -> T_VA_DCL . { T_LBRACE }\l"]; + q96 [label="96:\l declaration_list -> declaration . { T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q97 [label="97:\l function_definition -> declarator $$4 opt_declaration_list . T_LBRACE T_MATCHRBRACE\l"]; + q98 [label="98:\l declaration -> . decl_specifiers ';'\l declaration -> . decl_specifiers init_declarator_list ';'\l declaration -> . any_typedef decl_specifiers $$1 opt_declarator_list ';'\l any_typedef -> . T_EXTENSION T_TYPEDEF\l any_typedef -> . T_TYPEDEF\l opt_declaration_list -> declaration_list . { T_LBRACE }\l declaration_list -> declaration_list . declaration\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l"]; + q99 [label="99:\l decl_specifiers -> decl_specifiers . decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l parameter_declaration -> decl_specifiers . declarator\l parameter_declaration -> decl_specifiers . abs_declarator\l parameter_declaration -> decl_specifiers . { ')' ',' }\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l abs_declarator -> . pointer\l abs_declarator -> . pointer direct_abs_declarator\l abs_declarator -> . direct_abs_declarator\l direct_abs_declarator -> . '(' abs_declarator ')'\l direct_abs_declarator -> . direct_abs_declarator T_BRACKETS\l direct_abs_declarator -> . T_BRACKETS\l direct_abs_declarator -> . direct_abs_declarator '(' parameter_type_list ')'\l direct_abs_declarator -> . direct_abs_declarator '(' ')'\l direct_abs_declarator -> . '(' parameter_type_list ')'\l direct_abs_declarator -> . '(' ')'\l"]; + q100 [label="100:\l direct_declarator -> direct_declarator '(' parameter_type_list . ')'\l"]; + q101 [label="101:\l parameter_type_list -> parameter_list . { ')' }\l parameter_type_list -> parameter_list . ',' T_ELLIPSIS\l parameter_list -> parameter_list . ',' parameter_declaration\l"]; + q102 [label="102:\l parameter_list -> parameter_declaration . { ')' ',' }\l"]; + q103 [label="103:\l direct_declarator -> direct_declarator '(' opt_identifier_list . ')'\l"]; + q104 [label="104:\l opt_identifier_list -> identifier_list . { ')' }\l identifier_list -> identifier_list . ',' any_id\l"]; + q105 [label="105:\l identifier_list -> any_id . { ')' ',' }\l"]; + q106 [label="106:\l braces -> T_LBRACE T_MATCHRBRACE . { ')' ',' ';' T_ASM T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q107 [label="107:\l struct_or_union_specifier -> struct_or_union any_id braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q108 [label="108:\l enum_specifier -> enumeration any_id braces . { ')' ',' ';' T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' }\l"]; + q109 [label="109:\l declaration -> any_typedef decl_specifiers $$1 . opt_declarator_list ';'\l opt_declarator_list -> . { ';' }\l opt_declarator_list -> . declarator_list\l declarator_list -> . declarator\l declarator_list -> . declarator_list ',' declarator\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q110 [label="110:\l init_declarator -> declarator . { ',' ';' }\l init_declarator -> declarator . '=' $$5 T_INITIALIZER\l"]; + q111 [label="111:\l init_declarator_list -> init_declarator_list ',' init_declarator . { ',' ';' }\l"]; + q112 [label="112:\l init_declarator -> declarator '=' $$5 . T_INITIALIZER\l"]; + q113 [label="113:\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list . T_LBRACE $$3 T_MATCHRBRACE\l"]; + q114 [label="114:\l function_definition -> declarator $$4 opt_declaration_list T_LBRACE . T_MATCHRBRACE\l"]; + q115 [label="115:\l declaration_list -> declaration_list declaration . { T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME }\l"]; + q116 [label="116:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> '(' . declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l parameter_type_list -> . parameter_list\l parameter_type_list -> . parameter_list ',' T_ELLIPSIS\l parameter_list -> . parameter_declaration\l parameter_list -> . parameter_list ',' parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l abs_declarator -> . pointer\l abs_declarator -> . pointer direct_abs_declarator\l abs_declarator -> . direct_abs_declarator\l direct_abs_declarator -> . '(' abs_declarator ')'\l direct_abs_declarator -> '(' . abs_declarator ')'\l direct_abs_declarator -> . direct_abs_declarator T_BRACKETS\l direct_abs_declarator -> . T_BRACKETS\l direct_abs_declarator -> . direct_abs_declarator '(' parameter_type_list ')'\l direct_abs_declarator -> . direct_abs_declarator '(' ')'\l direct_abs_declarator -> . '(' parameter_type_list ')'\l direct_abs_declarator -> '(' . parameter_type_list ')'\l direct_abs_declarator -> . '(' ')'\l direct_abs_declarator -> '(' . ')'\l"]; + q117 [label="117:\l direct_abs_declarator -> T_BRACKETS . { ')' ',' T_BRACKETS '(' }\l"]; + q118 [label="118:\l parameter_declaration -> decl_specifiers declarator . { ')' ',' }\l"]; + q119 [label="119:\l parameter_declaration -> decl_specifiers abs_declarator . { ')' ',' }\l"]; + q120 [label="120:\l abs_declarator -> direct_abs_declarator . { ')' ',' }\l direct_abs_declarator -> direct_abs_declarator . T_BRACKETS\l direct_abs_declarator -> direct_abs_declarator . '(' parameter_type_list ')'\l direct_abs_declarator -> direct_abs_declarator . '(' ')'\l"]; + q121 [label="121:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> pointer . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l abs_declarator -> pointer . { ')' ',' }\l abs_declarator -> pointer . direct_abs_declarator\l direct_abs_declarator -> . '(' abs_declarator ')'\l direct_abs_declarator -> . direct_abs_declarator T_BRACKETS\l direct_abs_declarator -> . T_BRACKETS\l direct_abs_declarator -> . direct_abs_declarator '(' parameter_type_list ')'\l direct_abs_declarator -> . direct_abs_declarator '(' ')'\l direct_abs_declarator -> . '(' parameter_type_list ')'\l direct_abs_declarator -> . '(' ')'\l"]; + q122 [label="122:\l direct_declarator -> direct_declarator '(' parameter_type_list ')' . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q123 [label="123:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l parameter_type_list -> parameter_list ',' . T_ELLIPSIS\l parameter_list -> parameter_list ',' . parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l"]; + q124 [label="124:\l direct_declarator -> direct_declarator '(' opt_identifier_list ')' . { ')' '=' ',' ';' T_VA_DCL T_LBRACE T_BRACKETS T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME '(' }\l"]; + q125 [label="125:\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l identifier_list -> identifier_list ',' . any_id\l"]; + q126 [label="126:\l declarator_list -> declarator . { ',' ';' }\l"]; + q127 [label="127:\l declaration -> any_typedef decl_specifiers $$1 opt_declarator_list . ';'\l"]; + q128 [label="128:\l opt_declarator_list -> declarator_list . { ';' }\l declarator_list -> declarator_list . ',' declarator\l"]; + q129 [label="129:\l init_declarator -> declarator '=' $$5 T_INITIALIZER . { ',' ';' }\l"]; + q130 [label="130:\l $$3 -> . { T_MATCHRBRACE }\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list T_LBRACE . $$3 T_MATCHRBRACE\l"]; + q131 [label="131:\l function_definition -> declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q132 [label="132:\l direct_abs_declarator -> '(' ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q133 [label="133:\l direct_abs_declarator -> '(' abs_declarator . ')'\l"]; + q134 [label="134:\l direct_abs_declarator -> '(' parameter_type_list . ')'\l"]; + q135 [label="135:\l decl_specifiers -> . decl_specifier\l decl_specifiers -> . decl_specifiers decl_specifier\l decl_specifier -> . storage_class\l decl_specifier -> . type_specifier\l decl_specifier -> . type_qualifier\l storage_class -> . T_AUTO\l storage_class -> . T_EXTERN\l storage_class -> . T_REGISTER\l storage_class -> . T_STATIC\l storage_class -> . T_INLINE\l storage_class -> . T_EXTENSION\l type_specifier -> . T_CHAR\l type_specifier -> . T_DOUBLE\l type_specifier -> . T_FLOAT\l type_specifier -> . T_INT\l type_specifier -> . T_LONG\l type_specifier -> . T_SHORT\l type_specifier -> . T_SIGNED\l type_specifier -> . T_UNSIGNED\l type_specifier -> . T_VOID\l type_specifier -> . T_Bool\l type_specifier -> . T_Complex\l type_specifier -> . T_Imaginary\l type_specifier -> . T_TYPEDEF_NAME\l type_specifier -> . struct_or_union_specifier\l type_specifier -> . enum_specifier\l type_qualifier -> . T_TYPE_QUALIFIER\l type_qualifier -> . T_DEFINE_NAME\l struct_or_union_specifier -> . struct_or_union any_id braces\l struct_or_union_specifier -> . struct_or_union braces\l struct_or_union_specifier -> . struct_or_union any_id\l struct_or_union -> . T_STRUCT\l struct_or_union -> . T_UNION\l enum_specifier -> . enumeration any_id braces\l enum_specifier -> . enumeration braces\l enum_specifier -> . enumeration any_id\l enumeration -> . T_ENUM\l parameter_type_list -> . parameter_list\l parameter_type_list -> . parameter_list ',' T_ELLIPSIS\l parameter_list -> . parameter_declaration\l parameter_list -> . parameter_list ',' parameter_declaration\l parameter_declaration -> . decl_specifiers declarator\l parameter_declaration -> . decl_specifiers abs_declarator\l parameter_declaration -> . decl_specifiers\l direct_abs_declarator -> direct_abs_declarator '(' . parameter_type_list ')'\l direct_abs_declarator -> direct_abs_declarator '(' . ')'\l"]; + q136 [label="136:\l direct_abs_declarator -> direct_abs_declarator T_BRACKETS . { ')' ',' T_BRACKETS '(' }\l"]; + q137 [label="137:\l abs_declarator -> pointer direct_abs_declarator . { ')' ',' }\l direct_abs_declarator -> direct_abs_declarator . T_BRACKETS\l direct_abs_declarator -> direct_abs_declarator . '(' parameter_type_list ')'\l direct_abs_declarator -> direct_abs_declarator . '(' ')'\l"]; + q138 [label="138:\l parameter_type_list -> parameter_list ',' T_ELLIPSIS . { ')' }\l"]; + q139 [label="139:\l parameter_list -> parameter_list ',' parameter_declaration . { ')' ',' }\l"]; + q140 [label="140:\l identifier_list -> identifier_list ',' any_id . { ')' ',' }\l"]; + q141 [label="141:\l declaration -> any_typedef decl_specifiers $$1 opt_declarator_list ';' . { ';' T_ASM T_LBRACE T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q142 [label="142:\l declarator_list -> declarator_list ',' . declarator\l any_id -> . T_IDENTIFIER\l any_id -> . T_TYPEDEF_NAME\l declarator -> . pointer direct_declarator\l declarator -> . direct_declarator\l direct_declarator -> . identifier_or_ref\l direct_declarator -> . '(' declarator ')'\l direct_declarator -> . direct_declarator T_BRACKETS\l direct_declarator -> . direct_declarator '(' parameter_type_list ')'\l direct_declarator -> . direct_declarator '(' opt_identifier_list ')'\l pointer -> . '*' opt_type_qualifiers\l pointer -> . '*' opt_type_qualifiers pointer\l identifier_or_ref -> . any_id\l identifier_or_ref -> . '&' any_id\l"]; + q143 [label="143:\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 . T_MATCHRBRACE\l"]; + q144 [label="144:\l direct_abs_declarator -> '(' abs_declarator ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q145 [label="145:\l direct_abs_declarator -> '(' parameter_type_list ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q146 [label="146:\l direct_abs_declarator -> direct_abs_declarator '(' ')' . { ')' ',' T_BRACKETS '(' }\l"]; + q147 [label="147:\l direct_abs_declarator -> direct_abs_declarator '(' parameter_type_list . ')'\l"]; + q148 [label="148:\l declarator_list -> declarator_list ',' declarator . { ',' ';' }\l"]; + q149 [label="149:\l function_definition -> decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE . { ';' T_ASM T_TYPE_QUALIFIER T_Imaginary T_Complex T_Bool T_UNION T_STRUCT T_ENUM T_UNSIGNED T_SIGNED T_SHORT T_LONG T_VOID T_INT T_FLOAT T_DOUBLE T_CHAR T_EXTENSION T_INLINE T_TYPEDEF T_STATIC T_REGISTER T_EXTERN T_AUTO T_DEFINE_NAME T_TYPEDEF_NAME T_IDENTIFIER '&' '*' '(' error $end }\l"]; + q150 [label="150:\l direct_abs_declarator -> direct_abs_declarator '(' parameter_type_list ')' . { ')' ',' T_BRACKETS '(' }\l"]; + + q0 -> q1 [label="error"]; + q0 -> q2 [label="'('"]; + q0 -> q3 [label="'*'"]; + q0 -> q4 [label="'&'"]; + q0 -> q5 [label="T_IDENTIFIER"]; + q0 -> q6 [label="T_TYPEDEF_NAME"]; + q0 -> q7 [label="T_DEFINE_NAME"]; + q0 -> q8 [label="T_AUTO"]; + q0 -> q9 [label="T_EXTERN"]; + q0 -> q10 [label="T_REGISTER"]; + q0 -> q11 [label="T_STATIC"]; + q0 -> q12 [label="T_TYPEDEF"]; + q0 -> q13 [label="T_INLINE"]; + q0 -> q14 [label="T_EXTENSION"]; + q0 -> q15 [label="T_CHAR"]; + q0 -> q16 [label="T_DOUBLE"]; + q0 -> q17 [label="T_FLOAT"]; + q0 -> q18 [label="T_INT"]; + q0 -> q19 [label="T_VOID"]; + q0 -> q20 [label="T_LONG"]; + q0 -> q21 [label="T_SHORT"]; + q0 -> q22 [label="T_SIGNED"]; + q0 -> q23 [label="T_UNSIGNED"]; + q0 -> q24 [label="T_ENUM"]; + q0 -> q25 [label="T_STRUCT"]; + q0 -> q26 [label="T_UNION"]; + q0 -> q27 [label="T_Bool"]; + q0 -> q28 [label="T_Complex"]; + q0 -> q29 [label="T_Imaginary"]; + q0 -> q30 [label="T_TYPE_QUALIFIER"]; + q0 -> q31 [label="T_ASM"]; + q0 -> q32 [label="';'"]; + q0 -> q33 [label="program"]; + q0 -> q34 [label="decl_specifiers"]; + q0 -> q35 [label="decl_specifier"]; + q0 -> q36 [label="storage_class"]; + q0 -> q37 [label="type_specifier"]; + q0 -> q38 [label="type_qualifier"]; + q0 -> q39 [label="struct_or_union_specifier"]; + q0 -> q40 [label="enum_specifier"]; + q0 -> q41 [label="declarator"]; + q0 -> q42 [label="direct_declarator"]; + q0 -> q43 [label="struct_or_union"]; + q0 -> q44 [label="pointer"]; + q0 -> q45 [label="any_id"]; + q0 -> q46 [label="identifier_or_ref"]; + q0 -> q47 [label="enumeration"]; + q0 -> q48 [label="translation_unit"]; + q0 -> q49 [label="external_declaration"]; + q0 -> q50 [label="declaration"]; + q0 -> q51 [label="function_definition"]; + q0 -> q52 [label="linkage_specification"]; + q0 -> q53 [label="any_typedef"]; + q1 -> q54 [label="T_MATCHRBRACE"]; + q1 -> q55 [label="';'"]; + q2 -> q2 [label="'('"]; + q2 -> q3 [label="'*'"]; + q2 -> q4 [label="'&'"]; + q2 -> q5 [label="T_IDENTIFIER"]; + q2 -> q56 [label="T_TYPEDEF_NAME"]; + q2 -> q57 [label="declarator"]; + q2 -> q42 [label="direct_declarator"]; + q2 -> q44 [label="pointer"]; + q2 -> q45 [label="any_id"]; + q2 -> q46 [label="identifier_or_ref"]; + q3 -> q7 [label="T_DEFINE_NAME"]; + q3 -> q30 [label="T_TYPE_QUALIFIER"]; + q3 -> q58 [label="type_qualifier"]; + q3 -> q59 [label="opt_type_qualifiers"]; + q3 -> q60 [label="type_qualifier_list"]; + q4 -> q5 [label="T_IDENTIFIER"]; + q4 -> q56 [label="T_TYPEDEF_NAME"]; + q4 -> q61 [label="any_id"]; + q9 -> q62 [label="T_STRING_LITERAL"]; + q14 -> q63 [label="T_TYPEDEF"]; + q31 -> q64 [label="T_ASMARG"]; + q34 -> q2 [label="'('"]; + q34 -> q3 [label="'*'"]; + q34 -> q4 [label="'&'"]; + q34 -> q5 [label="T_IDENTIFIER"]; + q34 -> q6 [label="T_TYPEDEF_NAME"]; + q34 -> q7 [label="T_DEFINE_NAME"]; + q34 -> q8 [label="T_AUTO"]; + q34 -> q65 [label="T_EXTERN"]; + q34 -> q10 [label="T_REGISTER"]; + q34 -> q11 [label="T_STATIC"]; + q34 -> q13 [label="T_INLINE"]; + q34 -> q66 [label="T_EXTENSION"]; + q34 -> q15 [label="T_CHAR"]; + q34 -> q16 [label="T_DOUBLE"]; + q34 -> q17 [label="T_FLOAT"]; + q34 -> q18 [label="T_INT"]; + q34 -> q19 [label="T_VOID"]; + q34 -> q20 [label="T_LONG"]; + q34 -> q21 [label="T_SHORT"]; + q34 -> q22 [label="T_SIGNED"]; + q34 -> q23 [label="T_UNSIGNED"]; + q34 -> q24 [label="T_ENUM"]; + q34 -> q25 [label="T_STRUCT"]; + q34 -> q26 [label="T_UNION"]; + q34 -> q27 [label="T_Bool"]; + q34 -> q28 [label="T_Complex"]; + q34 -> q29 [label="T_Imaginary"]; + q34 -> q30 [label="T_TYPE_QUALIFIER"]; + q34 -> q67 [label="';'"]; + q34 -> q68 [label="decl_specifier"]; + q34 -> q36 [label="storage_class"]; + q34 -> q37 [label="type_specifier"]; + q34 -> q38 [label="type_qualifier"]; + q34 -> q39 [label="struct_or_union_specifier"]; + q34 -> q40 [label="enum_specifier"]; + q34 -> q69 [label="init_declarator_list"]; + q34 -> q70 [label="init_declarator"]; + q34 -> q71 [label="declarator"]; + q34 -> q42 [label="direct_declarator"]; + q34 -> q43 [label="struct_or_union"]; + q34 -> q44 [label="pointer"]; + q34 -> q45 [label="any_id"]; + q34 -> q46 [label="identifier_or_ref"]; + q34 -> q47 [label="enumeration"]; + q41 -> q72 [label="$$4"]; + q42 -> q73 [label="'('"]; + q42 -> q74 [label="T_BRACKETS"]; + q43 -> q5 [label="T_IDENTIFIER"]; + q43 -> q56 [label="T_TYPEDEF_NAME"]; + q43 -> q75 [label="T_LBRACE"]; + q43 -> q76 [label="any_id"]; + q43 -> q77 [label="braces"]; + q44 -> q2 [label="'('"]; + q44 -> q4 [label="'&'"]; + q44 -> q5 [label="T_IDENTIFIER"]; + q44 -> q56 [label="T_TYPEDEF_NAME"]; + q44 -> q78 [label="direct_declarator"]; + q44 -> q45 [label="any_id"]; + q44 -> q46 [label="identifier_or_ref"]; + q47 -> q5 [label="T_IDENTIFIER"]; + q47 -> q56 [label="T_TYPEDEF_NAME"]; + q47 -> q75 [label="T_LBRACE"]; + q47 -> q79 [label="any_id"]; + q47 -> q80 [label="braces"]; + q48 -> q1 [label="error"]; + q48 -> q2 [label="'('"]; + q48 -> q3 [label="'*'"]; + q48 -> q4 [label="'&'"]; + q48 -> q5 [label="T_IDENTIFIER"]; + q48 -> q6 [label="T_TYPEDEF_NAME"]; + q48 -> q7 [label="T_DEFINE_NAME"]; + q48 -> q8 [label="T_AUTO"]; + q48 -> q9 [label="T_EXTERN"]; + q48 -> q10 [label="T_REGISTER"]; + q48 -> q11 [label="T_STATIC"]; + q48 -> q12 [label="T_TYPEDEF"]; + q48 -> q13 [label="T_INLINE"]; + q48 -> q14 [label="T_EXTENSION"]; + q48 -> q15 [label="T_CHAR"]; + q48 -> q16 [label="T_DOUBLE"]; + q48 -> q17 [label="T_FLOAT"]; + q48 -> q18 [label="T_INT"]; + q48 -> q19 [label="T_VOID"]; + q48 -> q20 [label="T_LONG"]; + q48 -> q21 [label="T_SHORT"]; + q48 -> q22 [label="T_SIGNED"]; + q48 -> q23 [label="T_UNSIGNED"]; + q48 -> q24 [label="T_ENUM"]; + q48 -> q25 [label="T_STRUCT"]; + q48 -> q26 [label="T_UNION"]; + q48 -> q27 [label="T_Bool"]; + q48 -> q28 [label="T_Complex"]; + q48 -> q29 [label="T_Imaginary"]; + q48 -> q30 [label="T_TYPE_QUALIFIER"]; + q48 -> q31 [label="T_ASM"]; + q48 -> q32 [label="';'"]; + q48 -> q34 [label="decl_specifiers"]; + q48 -> q35 [label="decl_specifier"]; + q48 -> q36 [label="storage_class"]; + q48 -> q37 [label="type_specifier"]; + q48 -> q38 [label="type_qualifier"]; + q48 -> q39 [label="struct_or_union_specifier"]; + q48 -> q40 [label="enum_specifier"]; + q48 -> q41 [label="declarator"]; + q48 -> q42 [label="direct_declarator"]; + q48 -> q43 [label="struct_or_union"]; + q48 -> q44 [label="pointer"]; + q48 -> q45 [label="any_id"]; + q48 -> q46 [label="identifier_or_ref"]; + q48 -> q47 [label="enumeration"]; + q48 -> q81 [label="external_declaration"]; + q48 -> q50 [label="declaration"]; + q48 -> q51 [label="function_definition"]; + q48 -> q52 [label="linkage_specification"]; + q48 -> q53 [label="any_typedef"]; + q53 -> q82 [label="T_TYPEDEF_NAME"]; + q53 -> q7 [label="T_DEFINE_NAME"]; + q53 -> q8 [label="T_AUTO"]; + q53 -> q65 [label="T_EXTERN"]; + q53 -> q10 [label="T_REGISTER"]; + q53 -> q11 [label="T_STATIC"]; + q53 -> q13 [label="T_INLINE"]; + q53 -> q66 [label="T_EXTENSION"]; + q53 -> q15 [label="T_CHAR"]; + q53 -> q16 [label="T_DOUBLE"]; + q53 -> q17 [label="T_FLOAT"]; + q53 -> q18 [label="T_INT"]; + q53 -> q19 [label="T_VOID"]; + q53 -> q20 [label="T_LONG"]; + q53 -> q21 [label="T_SHORT"]; + q53 -> q22 [label="T_SIGNED"]; + q53 -> q23 [label="T_UNSIGNED"]; + q53 -> q24 [label="T_ENUM"]; + q53 -> q25 [label="T_STRUCT"]; + q53 -> q26 [label="T_UNION"]; + q53 -> q27 [label="T_Bool"]; + q53 -> q28 [label="T_Complex"]; + q53 -> q29 [label="T_Imaginary"]; + q53 -> q30 [label="T_TYPE_QUALIFIER"]; + q53 -> q83 [label="decl_specifiers"]; + q53 -> q35 [label="decl_specifier"]; + q53 -> q36 [label="storage_class"]; + q53 -> q37 [label="type_specifier"]; + q53 -> q38 [label="type_qualifier"]; + q53 -> q39 [label="struct_or_union_specifier"]; + q53 -> q40 [label="enum_specifier"]; + q53 -> q43 [label="struct_or_union"]; + q53 -> q47 [label="enumeration"]; + q57 -> q84 [label="')'"]; + q59 -> q3 [label="'*'"]; + q59 -> q85 [label="pointer"]; + q60 -> q7 [label="T_DEFINE_NAME"]; + q60 -> q30 [label="T_TYPE_QUALIFIER"]; + q60 -> q86 [label="type_qualifier"]; + q62 -> q82 [label="T_TYPEDEF_NAME"]; + q62 -> q7 [label="T_DEFINE_NAME"]; + q62 -> q8 [label="T_AUTO"]; + q62 -> q65 [label="T_EXTERN"]; + q62 -> q10 [label="T_REGISTER"]; + q62 -> q11 [label="T_STATIC"]; + q62 -> q12 [label="T_TYPEDEF"]; + q62 -> q13 [label="T_INLINE"]; + q62 -> q14 [label="T_EXTENSION"]; + q62 -> q15 [label="T_CHAR"]; + q62 -> q16 [label="T_DOUBLE"]; + q62 -> q17 [label="T_FLOAT"]; + q62 -> q18 [label="T_INT"]; + q62 -> q19 [label="T_VOID"]; + q62 -> q20 [label="T_LONG"]; + q62 -> q21 [label="T_SHORT"]; + q62 -> q22 [label="T_SIGNED"]; + q62 -> q23 [label="T_UNSIGNED"]; + q62 -> q24 [label="T_ENUM"]; + q62 -> q25 [label="T_STRUCT"]; + q62 -> q26 [label="T_UNION"]; + q62 -> q27 [label="T_Bool"]; + q62 -> q28 [label="T_Complex"]; + q62 -> q29 [label="T_Imaginary"]; + q62 -> q30 [label="T_TYPE_QUALIFIER"]; + q62 -> q75 [label="T_LBRACE"]; + q62 -> q87 [label="decl_specifiers"]; + q62 -> q35 [label="decl_specifier"]; + q62 -> q36 [label="storage_class"]; + q62 -> q37 [label="type_specifier"]; + q62 -> q38 [label="type_qualifier"]; + q62 -> q39 [label="struct_or_union_specifier"]; + q62 -> q40 [label="enum_specifier"]; + q62 -> q43 [label="struct_or_union"]; + q62 -> q47 [label="enumeration"]; + q62 -> q88 [label="declaration"]; + q62 -> q89 [label="braces"]; + q62 -> q53 [label="any_typedef"]; + q64 -> q90 [label="';'"]; + q69 -> q91 [label="';'"]; + q69 -> q92 [label="','"]; + q71 -> q93 [label="'='"]; + q71 -> q94 [label="$$2"]; + q72 -> q82 [label="T_TYPEDEF_NAME"]; + q72 -> q7 [label="T_DEFINE_NAME"]; + q72 -> q8 [label="T_AUTO"]; + q72 -> q65 [label="T_EXTERN"]; + q72 -> q10 [label="T_REGISTER"]; + q72 -> q11 [label="T_STATIC"]; + q72 -> q12 [label="T_TYPEDEF"]; + q72 -> q13 [label="T_INLINE"]; + q72 -> q14 [label="T_EXTENSION"]; + q72 -> q15 [label="T_CHAR"]; + q72 -> q16 [label="T_DOUBLE"]; + q72 -> q17 [label="T_FLOAT"]; + q72 -> q18 [label="T_INT"]; + q72 -> q19 [label="T_VOID"]; + q72 -> q20 [label="T_LONG"]; + q72 -> q21 [label="T_SHORT"]; + q72 -> q22 [label="T_SIGNED"]; + q72 -> q23 [label="T_UNSIGNED"]; + q72 -> q24 [label="T_ENUM"]; + q72 -> q25 [label="T_STRUCT"]; + q72 -> q26 [label="T_UNION"]; + q72 -> q27 [label="T_Bool"]; + q72 -> q28 [label="T_Complex"]; + q72 -> q29 [label="T_Imaginary"]; + q72 -> q30 [label="T_TYPE_QUALIFIER"]; + q72 -> q95 [label="T_VA_DCL"]; + q72 -> q87 [label="decl_specifiers"]; + q72 -> q35 [label="decl_specifier"]; + q72 -> q36 [label="storage_class"]; + q72 -> q37 [label="type_specifier"]; + q72 -> q38 [label="type_qualifier"]; + q72 -> q39 [label="struct_or_union_specifier"]; + q72 -> q40 [label="enum_specifier"]; + q72 -> q43 [label="struct_or_union"]; + q72 -> q47 [label="enumeration"]; + q72 -> q96 [label="declaration"]; + q72 -> q53 [label="any_typedef"]; + q72 -> q97 [label="opt_declaration_list"]; + q72 -> q98 [label="declaration_list"]; + q73 -> q5 [label="T_IDENTIFIER"]; + q73 -> q6 [label="T_TYPEDEF_NAME"]; + q73 -> q7 [label="T_DEFINE_NAME"]; + q73 -> q8 [label="T_AUTO"]; + q73 -> q65 [label="T_EXTERN"]; + q73 -> q10 [label="T_REGISTER"]; + q73 -> q11 [label="T_STATIC"]; + q73 -> q13 [label="T_INLINE"]; + q73 -> q66 [label="T_EXTENSION"]; + q73 -> q15 [label="T_CHAR"]; + q73 -> q16 [label="T_DOUBLE"]; + q73 -> q17 [label="T_FLOAT"]; + q73 -> q18 [label="T_INT"]; + q73 -> q19 [label="T_VOID"]; + q73 -> q20 [label="T_LONG"]; + q73 -> q21 [label="T_SHORT"]; + q73 -> q22 [label="T_SIGNED"]; + q73 -> q23 [label="T_UNSIGNED"]; + q73 -> q24 [label="T_ENUM"]; + q73 -> q25 [label="T_STRUCT"]; + q73 -> q26 [label="T_UNION"]; + q73 -> q27 [label="T_Bool"]; + q73 -> q28 [label="T_Complex"]; + q73 -> q29 [label="T_Imaginary"]; + q73 -> q30 [label="T_TYPE_QUALIFIER"]; + q73 -> q99 [label="decl_specifiers"]; + q73 -> q35 [label="decl_specifier"]; + q73 -> q36 [label="storage_class"]; + q73 -> q37 [label="type_specifier"]; + q73 -> q38 [label="type_qualifier"]; + q73 -> q39 [label="struct_or_union_specifier"]; + q73 -> q40 [label="enum_specifier"]; + q73 -> q100 [label="parameter_type_list"]; + q73 -> q101 [label="parameter_list"]; + q73 -> q102 [label="parameter_declaration"]; + q73 -> q103 [label="opt_identifier_list"]; + q73 -> q104 [label="identifier_list"]; + q73 -> q43 [label="struct_or_union"]; + q73 -> q105 [label="any_id"]; + q73 -> q47 [label="enumeration"]; + q75 -> q106 [label="T_MATCHRBRACE"]; + q76 -> q75 [label="T_LBRACE"]; + q76 -> q107 [label="braces"]; + q78 -> q73 [label="'('"]; + q78 -> q74 [label="T_BRACKETS"]; + q79 -> q75 [label="T_LBRACE"]; + q79 -> q108 [label="braces"]; + q83 -> q82 [label="T_TYPEDEF_NAME"]; + q83 -> q7 [label="T_DEFINE_NAME"]; + q83 -> q8 [label="T_AUTO"]; + q83 -> q65 [label="T_EXTERN"]; + q83 -> q10 [label="T_REGISTER"]; + q83 -> q11 [label="T_STATIC"]; + q83 -> q13 [label="T_INLINE"]; + q83 -> q66 [label="T_EXTENSION"]; + q83 -> q15 [label="T_CHAR"]; + q83 -> q16 [label="T_DOUBLE"]; + q83 -> q17 [label="T_FLOAT"]; + q83 -> q18 [label="T_INT"]; + q83 -> q19 [label="T_VOID"]; + q83 -> q20 [label="T_LONG"]; + q83 -> q21 [label="T_SHORT"]; + q83 -> q22 [label="T_SIGNED"]; + q83 -> q23 [label="T_UNSIGNED"]; + q83 -> q24 [label="T_ENUM"]; + q83 -> q25 [label="T_STRUCT"]; + q83 -> q26 [label="T_UNION"]; + q83 -> q27 [label="T_Bool"]; + q83 -> q28 [label="T_Complex"]; + q83 -> q29 [label="T_Imaginary"]; + q83 -> q30 [label="T_TYPE_QUALIFIER"]; + q83 -> q68 [label="decl_specifier"]; + q83 -> q36 [label="storage_class"]; + q83 -> q37 [label="type_specifier"]; + q83 -> q38 [label="type_qualifier"]; + q83 -> q39 [label="struct_or_union_specifier"]; + q83 -> q40 [label="enum_specifier"]; + q83 -> q43 [label="struct_or_union"]; + q83 -> q47 [label="enumeration"]; + q83 -> q109 [label="$$1"]; + q87 -> q2 [label="'('"]; + q87 -> q3 [label="'*'"]; + q87 -> q4 [label="'&'"]; + q87 -> q5 [label="T_IDENTIFIER"]; + q87 -> q6 [label="T_TYPEDEF_NAME"]; + q87 -> q7 [label="T_DEFINE_NAME"]; + q87 -> q8 [label="T_AUTO"]; + q87 -> q65 [label="T_EXTERN"]; + q87 -> q10 [label="T_REGISTER"]; + q87 -> q11 [label="T_STATIC"]; + q87 -> q13 [label="T_INLINE"]; + q87 -> q66 [label="T_EXTENSION"]; + q87 -> q15 [label="T_CHAR"]; + q87 -> q16 [label="T_DOUBLE"]; + q87 -> q17 [label="T_FLOAT"]; + q87 -> q18 [label="T_INT"]; + q87 -> q19 [label="T_VOID"]; + q87 -> q20 [label="T_LONG"]; + q87 -> q21 [label="T_SHORT"]; + q87 -> q22 [label="T_SIGNED"]; + q87 -> q23 [label="T_UNSIGNED"]; + q87 -> q24 [label="T_ENUM"]; + q87 -> q25 [label="T_STRUCT"]; + q87 -> q26 [label="T_UNION"]; + q87 -> q27 [label="T_Bool"]; + q87 -> q28 [label="T_Complex"]; + q87 -> q29 [label="T_Imaginary"]; + q87 -> q30 [label="T_TYPE_QUALIFIER"]; + q87 -> q67 [label="';'"]; + q87 -> q68 [label="decl_specifier"]; + q87 -> q36 [label="storage_class"]; + q87 -> q37 [label="type_specifier"]; + q87 -> q38 [label="type_qualifier"]; + q87 -> q39 [label="struct_or_union_specifier"]; + q87 -> q40 [label="enum_specifier"]; + q87 -> q69 [label="init_declarator_list"]; + q87 -> q70 [label="init_declarator"]; + q87 -> q110 [label="declarator"]; + q87 -> q42 [label="direct_declarator"]; + q87 -> q43 [label="struct_or_union"]; + q87 -> q44 [label="pointer"]; + q87 -> q45 [label="any_id"]; + q87 -> q46 [label="identifier_or_ref"]; + q87 -> q47 [label="enumeration"]; + q92 -> q2 [label="'('"]; + q92 -> q3 [label="'*'"]; + q92 -> q4 [label="'&'"]; + q92 -> q5 [label="T_IDENTIFIER"]; + q92 -> q56 [label="T_TYPEDEF_NAME"]; + q92 -> q111 [label="init_declarator"]; + q92 -> q110 [label="declarator"]; + q92 -> q42 [label="direct_declarator"]; + q92 -> q44 [label="pointer"]; + q92 -> q45 [label="any_id"]; + q92 -> q46 [label="identifier_or_ref"]; + q93 -> q112 [label="$$5"]; + q94 -> q82 [label="T_TYPEDEF_NAME"]; + q94 -> q7 [label="T_DEFINE_NAME"]; + q94 -> q8 [label="T_AUTO"]; + q94 -> q65 [label="T_EXTERN"]; + q94 -> q10 [label="T_REGISTER"]; + q94 -> q11 [label="T_STATIC"]; + q94 -> q12 [label="T_TYPEDEF"]; + q94 -> q13 [label="T_INLINE"]; + q94 -> q14 [label="T_EXTENSION"]; + q94 -> q15 [label="T_CHAR"]; + q94 -> q16 [label="T_DOUBLE"]; + q94 -> q17 [label="T_FLOAT"]; + q94 -> q18 [label="T_INT"]; + q94 -> q19 [label="T_VOID"]; + q94 -> q20 [label="T_LONG"]; + q94 -> q21 [label="T_SHORT"]; + q94 -> q22 [label="T_SIGNED"]; + q94 -> q23 [label="T_UNSIGNED"]; + q94 -> q24 [label="T_ENUM"]; + q94 -> q25 [label="T_STRUCT"]; + q94 -> q26 [label="T_UNION"]; + q94 -> q27 [label="T_Bool"]; + q94 -> q28 [label="T_Complex"]; + q94 -> q29 [label="T_Imaginary"]; + q94 -> q30 [label="T_TYPE_QUALIFIER"]; + q94 -> q95 [label="T_VA_DCL"]; + q94 -> q87 [label="decl_specifiers"]; + q94 -> q35 [label="decl_specifier"]; + q94 -> q36 [label="storage_class"]; + q94 -> q37 [label="type_specifier"]; + q94 -> q38 [label="type_qualifier"]; + q94 -> q39 [label="struct_or_union_specifier"]; + q94 -> q40 [label="enum_specifier"]; + q94 -> q43 [label="struct_or_union"]; + q94 -> q47 [label="enumeration"]; + q94 -> q96 [label="declaration"]; + q94 -> q53 [label="any_typedef"]; + q94 -> q113 [label="opt_declaration_list"]; + q94 -> q98 [label="declaration_list"]; + q97 -> q114 [label="T_LBRACE"]; + q98 -> q82 [label="T_TYPEDEF_NAME"]; + q98 -> q7 [label="T_DEFINE_NAME"]; + q98 -> q8 [label="T_AUTO"]; + q98 -> q65 [label="T_EXTERN"]; + q98 -> q10 [label="T_REGISTER"]; + q98 -> q11 [label="T_STATIC"]; + q98 -> q12 [label="T_TYPEDEF"]; + q98 -> q13 [label="T_INLINE"]; + q98 -> q14 [label="T_EXTENSION"]; + q98 -> q15 [label="T_CHAR"]; + q98 -> q16 [label="T_DOUBLE"]; + q98 -> q17 [label="T_FLOAT"]; + q98 -> q18 [label="T_INT"]; + q98 -> q19 [label="T_VOID"]; + q98 -> q20 [label="T_LONG"]; + q98 -> q21 [label="T_SHORT"]; + q98 -> q22 [label="T_SIGNED"]; + q98 -> q23 [label="T_UNSIGNED"]; + q98 -> q24 [label="T_ENUM"]; + q98 -> q25 [label="T_STRUCT"]; + q98 -> q26 [label="T_UNION"]; + q98 -> q27 [label="T_Bool"]; + q98 -> q28 [label="T_Complex"]; + q98 -> q29 [label="T_Imaginary"]; + q98 -> q30 [label="T_TYPE_QUALIFIER"]; + q98 -> q87 [label="decl_specifiers"]; + q98 -> q35 [label="decl_specifier"]; + q98 -> q36 [label="storage_class"]; + q98 -> q37 [label="type_specifier"]; + q98 -> q38 [label="type_qualifier"]; + q98 -> q39 [label="struct_or_union_specifier"]; + q98 -> q40 [label="enum_specifier"]; + q98 -> q43 [label="struct_or_union"]; + q98 -> q47 [label="enumeration"]; + q98 -> q115 [label="declaration"]; + q98 -> q53 [label="any_typedef"]; + q99 -> q116 [label="'('"]; + q99 -> q3 [label="'*'"]; + q99 -> q4 [label="'&'"]; + q99 -> q5 [label="T_IDENTIFIER"]; + q99 -> q6 [label="T_TYPEDEF_NAME"]; + q99 -> q7 [label="T_DEFINE_NAME"]; + q99 -> q8 [label="T_AUTO"]; + q99 -> q65 [label="T_EXTERN"]; + q99 -> q10 [label="T_REGISTER"]; + q99 -> q11 [label="T_STATIC"]; + q99 -> q13 [label="T_INLINE"]; + q99 -> q66 [label="T_EXTENSION"]; + q99 -> q15 [label="T_CHAR"]; + q99 -> q16 [label="T_DOUBLE"]; + q99 -> q17 [label="T_FLOAT"]; + q99 -> q18 [label="T_INT"]; + q99 -> q19 [label="T_VOID"]; + q99 -> q20 [label="T_LONG"]; + q99 -> q21 [label="T_SHORT"]; + q99 -> q22 [label="T_SIGNED"]; + q99 -> q23 [label="T_UNSIGNED"]; + q99 -> q24 [label="T_ENUM"]; + q99 -> q25 [label="T_STRUCT"]; + q99 -> q26 [label="T_UNION"]; + q99 -> q27 [label="T_Bool"]; + q99 -> q28 [label="T_Complex"]; + q99 -> q29 [label="T_Imaginary"]; + q99 -> q30 [label="T_TYPE_QUALIFIER"]; + q99 -> q117 [label="T_BRACKETS"]; + q99 -> q68 [label="decl_specifier"]; + q99 -> q36 [label="storage_class"]; + q99 -> q37 [label="type_specifier"]; + q99 -> q38 [label="type_qualifier"]; + q99 -> q39 [label="struct_or_union_specifier"]; + q99 -> q40 [label="enum_specifier"]; + q99 -> q118 [label="declarator"]; + q99 -> q42 [label="direct_declarator"]; + q99 -> q119 [label="abs_declarator"]; + q99 -> q120 [label="direct_abs_declarator"]; + q99 -> q43 [label="struct_or_union"]; + q99 -> q121 [label="pointer"]; + q99 -> q45 [label="any_id"]; + q99 -> q46 [label="identifier_or_ref"]; + q99 -> q47 [label="enumeration"]; + q100 -> q122 [label="')'"]; + q101 -> q123 [label="','"]; + q103 -> q124 [label="')'"]; + q104 -> q125 [label="','"]; + q109 -> q2 [label="'('"]; + q109 -> q3 [label="'*'"]; + q109 -> q4 [label="'&'"]; + q109 -> q5 [label="T_IDENTIFIER"]; + q109 -> q56 [label="T_TYPEDEF_NAME"]; + q109 -> q126 [label="declarator"]; + q109 -> q42 [label="direct_declarator"]; + q109 -> q44 [label="pointer"]; + q109 -> q45 [label="any_id"]; + q109 -> q46 [label="identifier_or_ref"]; + q109 -> q127 [label="opt_declarator_list"]; + q109 -> q128 [label="declarator_list"]; + q110 -> q93 [label="'='"]; + q112 -> q129 [label="T_INITIALIZER"]; + q113 -> q130 [label="T_LBRACE"]; + q114 -> q131 [label="T_MATCHRBRACE"]; + q116 -> q116 [label="'('"]; + q116 -> q3 [label="'*'"]; + q116 -> q4 [label="'&'"]; + q116 -> q5 [label="T_IDENTIFIER"]; + q116 -> q6 [label="T_TYPEDEF_NAME"]; + q116 -> q7 [label="T_DEFINE_NAME"]; + q116 -> q8 [label="T_AUTO"]; + q116 -> q65 [label="T_EXTERN"]; + q116 -> q10 [label="T_REGISTER"]; + q116 -> q11 [label="T_STATIC"]; + q116 -> q13 [label="T_INLINE"]; + q116 -> q66 [label="T_EXTENSION"]; + q116 -> q15 [label="T_CHAR"]; + q116 -> q16 [label="T_DOUBLE"]; + q116 -> q17 [label="T_FLOAT"]; + q116 -> q18 [label="T_INT"]; + q116 -> q19 [label="T_VOID"]; + q116 -> q20 [label="T_LONG"]; + q116 -> q21 [label="T_SHORT"]; + q116 -> q22 [label="T_SIGNED"]; + q116 -> q23 [label="T_UNSIGNED"]; + q116 -> q24 [label="T_ENUM"]; + q116 -> q25 [label="T_STRUCT"]; + q116 -> q26 [label="T_UNION"]; + q116 -> q27 [label="T_Bool"]; + q116 -> q28 [label="T_Complex"]; + q116 -> q29 [label="T_Imaginary"]; + q116 -> q30 [label="T_TYPE_QUALIFIER"]; + q116 -> q117 [label="T_BRACKETS"]; + q116 -> q132 [label="')'"]; + q116 -> q99 [label="decl_specifiers"]; + q116 -> q35 [label="decl_specifier"]; + q116 -> q36 [label="storage_class"]; + q116 -> q37 [label="type_specifier"]; + q116 -> q38 [label="type_qualifier"]; + q116 -> q39 [label="struct_or_union_specifier"]; + q116 -> q40 [label="enum_specifier"]; + q116 -> q57 [label="declarator"]; + q116 -> q42 [label="direct_declarator"]; + q116 -> q133 [label="abs_declarator"]; + q116 -> q120 [label="direct_abs_declarator"]; + q116 -> q134 [label="parameter_type_list"]; + q116 -> q101 [label="parameter_list"]; + q116 -> q102 [label="parameter_declaration"]; + q116 -> q43 [label="struct_or_union"]; + q116 -> q121 [label="pointer"]; + q116 -> q45 [label="any_id"]; + q116 -> q46 [label="identifier_or_ref"]; + q116 -> q47 [label="enumeration"]; + q120 -> q135 [label="'('"]; + q120 -> q136 [label="T_BRACKETS"]; + q121 -> q116 [label="'('"]; + q121 -> q4 [label="'&'"]; + q121 -> q5 [label="T_IDENTIFIER"]; + q121 -> q56 [label="T_TYPEDEF_NAME"]; + q121 -> q117 [label="T_BRACKETS"]; + q121 -> q78 [label="direct_declarator"]; + q121 -> q137 [label="direct_abs_declarator"]; + q121 -> q45 [label="any_id"]; + q121 -> q46 [label="identifier_or_ref"]; + q123 -> q82 [label="T_TYPEDEF_NAME"]; + q123 -> q7 [label="T_DEFINE_NAME"]; + q123 -> q8 [label="T_AUTO"]; + q123 -> q65 [label="T_EXTERN"]; + q123 -> q10 [label="T_REGISTER"]; + q123 -> q11 [label="T_STATIC"]; + q123 -> q13 [label="T_INLINE"]; + q123 -> q66 [label="T_EXTENSION"]; + q123 -> q15 [label="T_CHAR"]; + q123 -> q16 [label="T_DOUBLE"]; + q123 -> q17 [label="T_FLOAT"]; + q123 -> q18 [label="T_INT"]; + q123 -> q19 [label="T_VOID"]; + q123 -> q20 [label="T_LONG"]; + q123 -> q21 [label="T_SHORT"]; + q123 -> q22 [label="T_SIGNED"]; + q123 -> q23 [label="T_UNSIGNED"]; + q123 -> q24 [label="T_ENUM"]; + q123 -> q25 [label="T_STRUCT"]; + q123 -> q26 [label="T_UNION"]; + q123 -> q27 [label="T_Bool"]; + q123 -> q28 [label="T_Complex"]; + q123 -> q29 [label="T_Imaginary"]; + q123 -> q30 [label="T_TYPE_QUALIFIER"]; + q123 -> q138 [label="T_ELLIPSIS"]; + q123 -> q99 [label="decl_specifiers"]; + q123 -> q35 [label="decl_specifier"]; + q123 -> q36 [label="storage_class"]; + q123 -> q37 [label="type_specifier"]; + q123 -> q38 [label="type_qualifier"]; + q123 -> q39 [label="struct_or_union_specifier"]; + q123 -> q40 [label="enum_specifier"]; + q123 -> q139 [label="parameter_declaration"]; + q123 -> q43 [label="struct_or_union"]; + q123 -> q47 [label="enumeration"]; + q125 -> q5 [label="T_IDENTIFIER"]; + q125 -> q56 [label="T_TYPEDEF_NAME"]; + q125 -> q140 [label="any_id"]; + q127 -> q141 [label="';'"]; + q128 -> q142 [label="','"]; + q130 -> q143 [label="$$3"]; + q133 -> q144 [label="')'"]; + q134 -> q145 [label="')'"]; + q135 -> q82 [label="T_TYPEDEF_NAME"]; + q135 -> q7 [label="T_DEFINE_NAME"]; + q135 -> q8 [label="T_AUTO"]; + q135 -> q65 [label="T_EXTERN"]; + q135 -> q10 [label="T_REGISTER"]; + q135 -> q11 [label="T_STATIC"]; + q135 -> q13 [label="T_INLINE"]; + q135 -> q66 [label="T_EXTENSION"]; + q135 -> q15 [label="T_CHAR"]; + q135 -> q16 [label="T_DOUBLE"]; + q135 -> q17 [label="T_FLOAT"]; + q135 -> q18 [label="T_INT"]; + q135 -> q19 [label="T_VOID"]; + q135 -> q20 [label="T_LONG"]; + q135 -> q21 [label="T_SHORT"]; + q135 -> q22 [label="T_SIGNED"]; + q135 -> q23 [label="T_UNSIGNED"]; + q135 -> q24 [label="T_ENUM"]; + q135 -> q25 [label="T_STRUCT"]; + q135 -> q26 [label="T_UNION"]; + q135 -> q27 [label="T_Bool"]; + q135 -> q28 [label="T_Complex"]; + q135 -> q29 [label="T_Imaginary"]; + q135 -> q30 [label="T_TYPE_QUALIFIER"]; + q135 -> q146 [label="')'"]; + q135 -> q99 [label="decl_specifiers"]; + q135 -> q35 [label="decl_specifier"]; + q135 -> q36 [label="storage_class"]; + q135 -> q37 [label="type_specifier"]; + q135 -> q38 [label="type_qualifier"]; + q135 -> q39 [label="struct_or_union_specifier"]; + q135 -> q40 [label="enum_specifier"]; + q135 -> q147 [label="parameter_type_list"]; + q135 -> q101 [label="parameter_list"]; + q135 -> q102 [label="parameter_declaration"]; + q135 -> q43 [label="struct_or_union"]; + q135 -> q47 [label="enumeration"]; + q137 -> q135 [label="'('"]; + q137 -> q136 [label="T_BRACKETS"]; + q142 -> q2 [label="'('"]; + q142 -> q3 [label="'*'"]; + q142 -> q4 [label="'&'"]; + q142 -> q5 [label="T_IDENTIFIER"]; + q142 -> q56 [label="T_TYPEDEF_NAME"]; + q142 -> q148 [label="declarator"]; + q142 -> q42 [label="direct_declarator"]; + q142 -> q44 [label="pointer"]; + q142 -> q45 [label="any_id"]; + q142 -> q46 [label="identifier_or_ref"]; + q143 -> q149 [label="T_MATCHRBRACE"]; + q147 -> q150 [label="')'"]; +} diff --git a/contrib/byacc/test/yacc/grammar.error b/contrib/byacc/test/yacc/grammar.error new file mode 100644 index 000000000..d442f8aba --- /dev/null +++ b/contrib/byacc/test/yacc/grammar.error @@ -0,0 +1 @@ +YACC: 1 shift/reduce conflict, 29 reduce/reduce conflicts. diff --git a/contrib/byacc/test/grammar.output b/contrib/byacc/test/yacc/grammar.output similarity index 100% rename from contrib/byacc/test/grammar.output rename to contrib/byacc/test/yacc/grammar.output diff --git a/contrib/byacc/test/grammar.tab.c b/contrib/byacc/test/yacc/grammar.tab.c similarity index 96% rename from contrib/byacc/test/grammar.tab.c rename to contrib/byacc/test/yacc/grammar.tab.c index 8065343db..e78f18815 100644 --- a/contrib/byacc/test/grammar.tab.c +++ b/contrib/byacc/test/yacc/grammar.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 grammar_parse @@ -382,7 +384,7 @@ haveAnsiParam (void) } return FALSE; } -#line 386 "grammar.tab.c" +#line 388 "grammar.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM @@ -451,7 +453,8 @@ extern int YYPARSE_DECL(); #define T_ASMARG 290 #define T_VA_DCL 291 #define YYERRCODE 256 -static const short grammar_lhs[] = { -1, +typedef short YYINT; +static const YYINT grammar_lhs[] = { -1, 0, 0, 26, 26, 27, 27, 27, 27, 27, 27, 27, 31, 30, 30, 28, 28, 34, 28, 32, 32, 33, 33, 35, 35, 37, 38, 29, 39, 29, 36, @@ -465,7 +468,7 @@ static const short grammar_lhs[] = { -1, 18, 18, 24, 24, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, }; -static const short grammar_len[] = { 2, +static const YYINT grammar_len[] = { 2, 0, 1, 1, 2, 1, 1, 1, 1, 3, 2, 2, 2, 3, 3, 2, 3, 0, 5, 2, 1, 0, 1, 1, 3, 0, 0, 7, 0, 5, 0, @@ -479,7 +482,7 @@ static const short grammar_len[] = { 2, 1, 3, 1, 2, 1, 2, 1, 3, 2, 1, 4, 3, 3, 2, }; -static const short grammar_defred[] = { 0, +static const YYINT grammar_defred[] = { 0, 0, 0, 0, 0, 77, 0, 62, 40, 0, 42, 43, 20, 44, 0, 46, 47, 48, 49, 54, 50, 51, 52, 53, 76, 66, 67, 55, 56, 57, 61, @@ -496,14 +499,14 @@ static const short grammar_defred[] = { 0, 29, 114, 0, 0, 0, 109, 0, 93, 95, 102, 18, 0, 0, 108, 113, 112, 0, 24, 27, 111, }; -static const short grammar_dgoto[] = { 33, +static const YYINT grammar_dgoto[] = { 33, 87, 35, 36, 37, 38, 39, 40, 69, 70, 41, 42, 119, 120, 100, 101, 102, 103, 104, 43, 44, 59, 60, 45, 46, 47, 48, 49, 50, 51, 52, 77, 53, 127, 109, 128, 97, 94, 143, 72, 98, 112, }; -static const short grammar_sindex[] = { -2, +static const YYINT grammar_sindex[] = { -2, -3, 27, -239, -177, 0, 0, 0, 0, -274, 0, 0, 0, 0, -246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -520,7 +523,7 @@ static const short grammar_sindex[] = { -2, 0, 0, 53, 55, 417, 0, -33, 0, 0, 0, 0, 27, -188, 0, 0, 0, 57, 0, 0, 0, }; -static const short grammar_rindex[] = { 99, +static const YYINT grammar_rindex[] = { 99, 0, 0, 275, 0, 0, -38, 0, 0, 481, 0, 0, 0, 0, 509, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -537,7 +540,7 @@ static const short grammar_rindex[] = { 99, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static const short grammar_gindex[] = { 0, +static const YYINT grammar_gindex[] = { 0, 11, -17, 0, 0, 13, 0, 0, 0, 20, 8, -43, -1, -8, -89, 0, -9, 0, 0, 0, -44, 0, 0, 4, 0, 0, 0, 70, -53, 0, 0, @@ -545,7 +548,7 @@ static const short grammar_gindex[] = { 0, 0, }; #define YYTABLESIZE 924 -static const short grammar_table[] = { 58, +static const YYINT grammar_table[] = { 58, 78, 58, 58, 58, 73, 58, 135, 61, 88, 57, 34, 5, 56, 62, 85, 58, 68, 63, 96, 7, 58, 98, 78, 64, 98, 84, 134, 107, 80, 3, @@ -640,7 +643,7 @@ static const short grammar_table[] = { 58, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, }; -static const short grammar_check[] = { 38, +static const YYINT grammar_check[] = { 38, 44, 40, 41, 42, 40, 44, 40, 4, 62, 2, 0, 257, 258, 288, 59, 3, 34, 264, 72, 259, 59, 41, 61, 290, 44, 41, 116, 41, 47, 42, @@ -740,8 +743,10 @@ static const short grammar_check[] = { 38, #define YYDEBUG 0 #endif #define YYMAXTOKEN 291 +#define YYUNDFTOKEN 335 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const grammar_name[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0, @@ -755,9 +760,11 @@ static const char *yyname[] = { "T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED", "T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary", "T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS", -"T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL", +"T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const grammar_rule[] = { "$accept : program", "program :", "program : translation_unit", @@ -893,18 +900,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -1081,7 +1088,7 @@ free_parser(void) #endif } #endif -#line 1085 "grammar.tab.c" +#line 1092 "grammar.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -1095,27 +1102,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -1165,7 +1172,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -1175,13 +1182,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -1195,7 +1200,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -1214,7 +1219,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -1235,7 +1240,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -1259,13 +1264,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -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; @@ -1979,19 +1982,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -2004,16 +2005,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/grammar.tab.h b/contrib/byacc/test/yacc/grammar.tab.h similarity index 100% rename from contrib/byacc/test/grammar.tab.h rename to contrib/byacc/test/yacc/grammar.tab.h diff --git a/contrib/byacc/test/yacc/help.error b/contrib/byacc/test/yacc/help.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/help.output b/contrib/byacc/test/yacc/help.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/yacc/help.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/yacc/no_b_opt.error b/contrib/byacc/test/yacc/no_b_opt.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_b_opt.output b/contrib/byacc/test/yacc/no_b_opt.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/yacc/no_b_opt.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/yacc/no_b_opt1.error b/contrib/byacc/test/yacc/no_b_opt1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_b_opt1.output b/contrib/byacc/test/yacc/no_b_opt1.output new file mode 100644 index 000000000..87286c266 --- /dev/null +++ b/contrib/byacc/test/yacc/no_b_opt1.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_code_c.error b/contrib/byacc/test/yacc/no_code_c.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_code_c.output b/contrib/byacc/test/yacc/no_code_c.output new file mode 100644 index 000000000..87286c266 --- /dev/null +++ b/contrib/byacc/test/yacc/no_code_c.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_defines.error b/contrib/byacc/test/yacc/no_defines.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_defines.output b/contrib/byacc/test/yacc/no_defines.output new file mode 100644 index 000000000..773985d66 --- /dev/null +++ b/contrib/byacc/test/yacc/no_defines.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.h" diff --git a/contrib/byacc/test/yacc/no_graph.error b/contrib/byacc/test/yacc/no_graph.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_graph.output b/contrib/byacc/test/yacc/no_graph.output new file mode 100644 index 000000000..d5575f400 --- /dev/null +++ b/contrib/byacc/test/yacc/no_graph.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.dot" diff --git a/contrib/byacc/test/yacc/no_include.error b/contrib/byacc/test/yacc/no_include.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_include.output b/contrib/byacc/test/yacc/no_include.output new file mode 100644 index 000000000..3ece4a454 --- /dev/null +++ b/contrib/byacc/test/yacc/no_include.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.i" diff --git a/contrib/byacc/test/yacc/no_opts.error b/contrib/byacc/test/yacc/no_opts.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_opts.output b/contrib/byacc/test/yacc/no_opts.output new file mode 100644 index 000000000..ad3131a69 --- /dev/null +++ b/contrib/byacc/test/yacc/no_opts.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.y" diff --git a/contrib/byacc/test/yacc/no_output.error b/contrib/byacc/test/yacc/no_output.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_output.output b/contrib/byacc/test/yacc/no_output.output new file mode 100644 index 000000000..a2f142a9d --- /dev/null +++ b/contrib/byacc/test/yacc/no_output.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/no_output1.error b/contrib/byacc/test/yacc/no_output1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_output1.output b/contrib/byacc/test/yacc/no_output1.output new file mode 100644 index 000000000..a2f142a9d --- /dev/null +++ b/contrib/byacc/test/yacc/no_output1.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/no_output2.error b/contrib/byacc/test/yacc/no_output2.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_output2.output b/contrib/byacc/test/yacc/no_output2.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/yacc/no_output2.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/yacc/no_p_opt.error b/contrib/byacc/test/yacc/no_p_opt.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_p_opt.output b/contrib/byacc/test/yacc/no_p_opt.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/yacc/no_p_opt.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/yacc/no_p_opt1.error b/contrib/byacc/test/yacc/no_p_opt1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_p_opt1.output b/contrib/byacc/test/yacc/no_p_opt1.output new file mode 100644 index 000000000..87286c266 --- /dev/null +++ b/contrib/byacc/test/yacc/no_p_opt1.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_verbose.error b/contrib/byacc/test/yacc/no_verbose.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/no_verbose.output b/contrib/byacc/test/yacc/no_verbose.output new file mode 100644 index 000000000..a2f142a9d --- /dev/null +++ b/contrib/byacc/test/yacc/no_verbose.output @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/nostdin.error b/contrib/byacc/test/yacc/nostdin.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/nostdin.output b/contrib/byacc/test/yacc/nostdin.output new file mode 100644 index 000000000..28e455543 --- /dev/null +++ b/contrib/byacc/test/yacc/nostdin.output @@ -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) + -D enable value stack memory reclamation + -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/contrib/byacc/test/yacc/ok_syntax1.error b/contrib/byacc/test/yacc/ok_syntax1.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/ok_syntax1.output b/contrib/byacc/test/yacc/ok_syntax1.output new file mode 100644 index 000000000..105a1d30d --- /dev/null +++ b/contrib/byacc/test/yacc/ok_syntax1.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 + '\n' reduce 15 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' 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 + '\n' reduce 16 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' 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 + '\n' reduce 13 + '|' 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 + '\n' reduce 12 + '|' reduce 12 + '&' 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 + '\n' reduce 7 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' 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 + '\n' reduce 8 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' 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 + + +42 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/contrib/byacc/test/yacc/ok_syntax1.tab.c b/contrib/byacc/test/yacc/ok_syntax1.tab.c new file mode 100644 index 000000000..990623e75 --- /dev/null +++ b/contrib/byacc/test/yacc/ok_syntax1.tab.c @@ -0,0 +1,716 @@ +/* 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 ok_syntax1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex ok_syntax1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror ok_syntax1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar ok_syntax1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval ok_syntax1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval ok_syntax1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug ok_syntax1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs ok_syntax1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag ok_syntax1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs ok_syntax1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen ok_syntax1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred ok_syntax1_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto ok_syntax1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex ok_syntax1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex ok_syntax1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex ok_syntax1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable ok_syntax1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck ok_syntax1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname ok_syntax1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule ok_syntax1_rule +#endif /* yyrule */ +#define YYPREFIX "ok_syntax1_" + +#define YYPURE 1 + +#line 9 "ok_syntax1.y" +# include +# include + +#ifdef YYBISON +#define YYSTYPE int +#define YYLEX_PARAM base +#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM) +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) +int YYLEX_DECL(); +static void YYERROR_DECL(); +#endif + +#line 43 "ok_syntax1.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + char * cval; + int ival; + double dval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 128 "ok_syntax1.tab.c" + +/* 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(int regs[26], int * base) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# ifdef YYLEX_PARAM_TYPE +# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) +# else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) +# endif +# define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base) +# define YYLEX yylex(&yylval, base) +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(regs, base, msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define OCT1 259 +#define HEX1 260 +#define HEX2 261 +#define HEX3 262 +#define STR1 263 +#define STR2 265 +#define BELL 266 +#define BS 267 +#define NL 268 +#define LF 269 +#define CR 270 +#define TAB 271 +#define VT 272 +#define UMINUS 273 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT ok_syntax1_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT ok_syntax1_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT ok_syntax1_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 ok_syntax1_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT ok_syntax1_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 ok_syntax1_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 ok_syntax1_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT ok_syntax1_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 ok_syntax1_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 273 +#define YYUNDFTOKEN 279 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const ok_syntax1_name[] = { + +"end-of-file",0,0,0,0,0,0,"'\\a'","'\\b'","'\\t'","'\\n'","'\\v'","'\\f'", +"'\\r'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'#'",0,"'%'","'&'",0,"'('", +"')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,"'@'",0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,"'~'","'\\177'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +"'\\377'",0,"DIGIT","LETTER","OCT1","HEX1","HEX2","HEX3","STR1", +"\"\\177\\177\\\\\\n\"","STR2","BELL","BS","NL","LF","CR","TAB","VT","UMINUS",0, +0,0,0,0,"illegal-symbol", +}; +static const char *const ok_syntax1_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 + +int yydebug; +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; +#line 104 "ok_syntax1.y" + /* start of programs */ + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main (void) +{ + int regs[26]; + int base = 10; + + while(!feof(stdin)) { + yyparse(regs, &base); + } + return 0; +} + +#define UNUSED(x) ((void)(x)) + +static void +YYERROR_DECL() +{ + UNUSED(regs); /* %parse-param regs is not actually used here */ + UNUSED(base); /* %parse-param base is not actually used here */ + fprintf(stderr, "%s\n", s); +} + +int +YYLEX_DECL() +{ + /* 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->ival = (c - 'a'); + return ( LETTER ); + } + if( isdigit( c )) { + yylval->ival = (c - '0') % (*base); + return ( DIGIT ); + } + return( c ); +} +#line 389 "ok_syntax1.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; + + /* variables for the parser stack */ + YYSTACKDATA yystack; + 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) == 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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 66 "ok_syntax1.y" + { yyerrok ; } +break; +case 4: +#line 70 "ok_syntax1.y" + { printf("%d\n",yystack.l_mark[0].ival);} +break; +case 5: +#line 72 "ok_syntax1.y" + { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } +break; +case 6: +#line 76 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-1].ival; } +break; +case 7: +#line 78 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } +break; +case 8: +#line 80 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } +break; +case 9: +#line 82 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } +break; +case 10: +#line 84 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } +break; +case 11: +#line 86 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } +break; +case 12: +#line 88 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } +break; +case 13: +#line 90 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } +break; +case 14: +#line 92 "ok_syntax1.y" + { yyval.ival = - yystack.l_mark[0].ival; } +break; +case 15: +#line 94 "ok_syntax1.y" + { yyval.ival = regs[yystack.l_mark[0].ival]; } +break; +case 17: +#line 99 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } +break; +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" + } + 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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/ok_syntax1.tab.h b/contrib/byacc/test/yacc/ok_syntax1.tab.h new file mode 100644 index 000000000..8a51fa006 --- /dev/null +++ b/contrib/byacc/test/yacc/ok_syntax1.tab.h @@ -0,0 +1,30 @@ +#define DIGIT 257 +#define LETTER 258 +#define OCT1 259 +#define HEX1 260 +#define HEX2 261 +#define HEX3 262 +#define STR1 263 +#define STR2 265 +#define BELL 266 +#define BS 267 +#define NL 268 +#define LF 269 +#define CR 270 +#define TAB 271 +#define VT 272 +#define UMINUS 273 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + char * cval; + int ival; + double dval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE ok_syntax1_lval; diff --git a/contrib/byacc/test/yacc/pure_calc.error b/contrib/byacc/test/yacc/pure_calc.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/pure_calc.output b/contrib/byacc/test/yacc/pure_calc.output similarity index 100% rename from contrib/byacc/test/pure_calc.output rename to contrib/byacc/test/yacc/pure_calc.output diff --git a/contrib/byacc/test/pure_calc.tab.c b/contrib/byacc/test/yacc/pure_calc.tab.c similarity index 87% rename from contrib/byacc/test/pure_calc.tab.c rename to contrib/byacc/test/yacc/pure_calc.tab.c index acba40412..911db408e 100644 --- a/contrib/byacc/test/pure_calc.tab.c +++ b/contrib/byacc/test/yacc/pure_calc.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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_parse @@ -111,10 +113,12 @@ int YYLEX_DECL(); static void YYERROR_DECL(); #endif -#line 115 "pure_calc.tab.c" +#line 117 "pure_calc.tab.c" -#ifndef YYSTYPE +#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 */ @@ -156,40 +160,41 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -static const short calc_lhs[] = { -1, +typedef short YYINT; +static const YYINT 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, +static const YYINT 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, +static const YYINT 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, +static const YYINT calc_dgoto[] = { 1, 7, 8, 9, }; -static const short calc_sindex[] = { 0, +static const YYINT 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, +static const YYINT 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, +static const YYINT calc_gindex[] = { 0, 0, 65, 0, }; #define YYTABLESIZE 220 -static const short calc_table[] = { 6, +static const YYINT 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, @@ -213,7 +218,7 @@ static const short calc_table[] = { 6, 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, +static const YYINT 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, @@ -242,8 +247,10 @@ static const short calc_check[] = { 40, #define YYDEBUG 0 #endif #define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const calc_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, @@ -252,9 +259,9 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const calc_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -289,18 +296,18 @@ int yynerrs; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -350,7 +357,7 @@ YYLEX_DECL() } return( c ); } -#line 354 "pure_calc.tab.c" +#line 361 "pure_calc.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -364,27 +371,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -441,7 +448,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -451,13 +458,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -471,7 +476,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -490,7 +495,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -511,7 +516,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -535,13 +540,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -623,7 +626,7 @@ case 18: #line 69 "pure_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 627 "pure_calc.tab.c" +#line 630 "pure_calc.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -641,19 +644,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -666,16 +667,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/pure_calc.tab.h b/contrib/byacc/test/yacc/pure_calc.tab.h similarity index 100% rename from contrib/byacc/test/pure_calc.tab.h rename to contrib/byacc/test/yacc/pure_calc.tab.h diff --git a/contrib/byacc/test/yacc/pure_error.error b/contrib/byacc/test/yacc/pure_error.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/pure_error.output b/contrib/byacc/test/yacc/pure_error.output similarity index 100% rename from contrib/byacc/test/pure_error.output rename to contrib/byacc/test/yacc/pure_error.output diff --git a/contrib/byacc/test/pure_error.tab.c b/contrib/byacc/test/yacc/pure_error.tab.c similarity index 78% rename from contrib/byacc/test/pure_error.tab.c rename to contrib/byacc/test/yacc/pure_error.tab.c index 55a7d7e53..0184e924f 100644 --- a/contrib/byacc/test/pure_error.tab.c +++ b/contrib/byacc/test/yacc/pure_error.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 error_parse @@ -106,10 +108,12 @@ int YYLEX_DECL(); static void YYERROR_DECL(); #endif -#line 110 "pure_error.tab.c" +#line 112 "pure_error.tab.c" -#ifndef YYSTYPE +#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 */ @@ -148,41 +152,50 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); #define YYERRCODE 256 -static const short error_lhs[] = { -1, +typedef short YYINT; +static const YYINT error_lhs[] = { -1, 0, }; -static const short error_len[] = { 2, +static const YYINT error_len[] = { 2, 1, }; -static const short error_defred[] = { 0, +static const YYINT error_defred[] = { 0, 1, 0, }; -static const short error_dgoto[] = { 2, +static const YYINT error_dgoto[] = { 2, }; -static const short error_sindex[] = { -256, +static const YYINT error_sindex[] = { -256, 0, 0, }; -static const short error_rindex[] = { 0, +static const YYINT error_rindex[] = { 0, 0, 0, }; -static const short error_gindex[] = { 0, +static const YYINT error_gindex[] = { 0, }; #define YYTABLESIZE 0 -static const short error_table[] = { 1, +static const YYINT error_table[] = { 1, }; -static const short error_check[] = { 256, +static const YYINT error_check[] = { 256, }; #define YYFINAL 2 #ifndef YYDEBUG #define YYDEBUG 0 #endif -#define YYMAXTOKEN 0 +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { - -"end-of-file", +static const char *const error_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const error_rule[] = { "$accept : S", "S : error", @@ -200,18 +213,18 @@ int yynerrs; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -241,7 +254,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 245 "pure_error.tab.c" +#line 258 "pure_error.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -255,27 +268,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -332,7 +345,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -342,13 +355,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -362,7 +373,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -381,7 +392,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -402,7 +413,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -426,13 +437,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -471,19 +480,17 @@ YYPARSE_DECL() *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -496,16 +503,16 @@ YYPARSE_DECL() 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/yacc/pure_error.tab.h b/contrib/byacc/test/yacc/pure_error.tab.h new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/quote_calc-s.error b/contrib/byacc/test/yacc/quote_calc-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc-s.output b/contrib/byacc/test/yacc/quote_calc-s.output similarity index 100% rename from contrib/byacc/test/quote_calc-s.output rename to contrib/byacc/test/yacc/quote_calc-s.output diff --git a/contrib/byacc/test/quote_calc-s.tab.c b/contrib/byacc/test/yacc/quote_calc-s.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc-s.tab.c rename to contrib/byacc/test/yacc/quote_calc-s.tab.c index ec4375d3d..9d4d7bd58 100644 --- a/contrib/byacc/test/quote_calc-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc-s.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc-s.tab.c" +#line 111 "quote_calc-s.tab.c" -#ifndef YYSTYPE +#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 */ @@ -152,40 +156,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc_len[] = { 2, +static const YYINT quote_calc_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc_defred[] = { 1, +static const YYINT quote_calc_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc_dgoto[] = { 1, +static const YYINT quote_calc_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc_sindex[] = { 0, +static const YYINT quote_calc_sindex[] = { 0, -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc_rindex[] = { 0, +static const YYINT quote_calc_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc_gindex[] = { 0, +static const YYINT quote_calc_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 258 -static const short quote_calc_table[] = { 16, +static const YYINT quote_calc_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, @@ -213,7 +218,7 @@ static const short quote_calc_table[] = { 16, 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc_check[] = { 10, +static const YYINT quote_calc_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, @@ -246,8 +251,10 @@ static const short quote_calc_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc_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, @@ -257,9 +264,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -299,18 +307,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -357,7 +365,7 @@ yylex(void) { } return( c ); } -#line 361 "quote_calc-s.tab.c" +#line 369 "quote_calc-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -371,27 +379,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -441,7 +449,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -451,13 +459,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -471,7 +477,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -490,7 +496,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -511,7 +517,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -535,13 +541,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -623,7 +627,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 627 "quote_calc-s.tab.c" +#line 631 "quote_calc-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -641,19 +645,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -666,16 +668,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc-s.tab.h b/contrib/byacc/test/yacc/quote_calc-s.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc-s.tab.h rename to contrib/byacc/test/yacc/quote_calc-s.tab.h diff --git a/contrib/byacc/test/yacc/quote_calc.error b/contrib/byacc/test/yacc/quote_calc.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc.output b/contrib/byacc/test/yacc/quote_calc.output similarity index 100% rename from contrib/byacc/test/quote_calc.output rename to contrib/byacc/test/yacc/quote_calc.output diff --git a/contrib/byacc/test/quote_calc.tab.c b/contrib/byacc/test/yacc/quote_calc.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc.tab.c rename to contrib/byacc/test/yacc/quote_calc.tab.c index d90061415..affdbe56d 100644 --- a/contrib/byacc/test/quote_calc.tab.c +++ b/contrib/byacc/test/yacc/quote_calc.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc.tab.c" +#line 111 "quote_calc.tab.c" -#ifndef YYSTYPE +#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 */ @@ -158,40 +162,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc_len[] = { 2, +static const YYINT quote_calc_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc_defred[] = { 1, +static const YYINT quote_calc_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc_dgoto[] = { 1, +static const YYINT quote_calc_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc_sindex[] = { 0, +static const YYINT quote_calc_sindex[] = { 0, -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc_rindex[] = { 0, +static const YYINT quote_calc_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc_gindex[] = { 0, +static const YYINT quote_calc_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 258 -static const short quote_calc_table[] = { 16, +static const YYINT quote_calc_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, @@ -219,7 +224,7 @@ static const short quote_calc_table[] = { 16, 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc_check[] = { 10, +static const YYINT quote_calc_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, @@ -252,8 +257,10 @@ static const short quote_calc_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc_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, @@ -263,9 +270,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -305,18 +313,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -363,7 +371,7 @@ yylex(void) { } return( c ); } -#line 367 "quote_calc.tab.c" +#line 375 "quote_calc.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -377,27 +385,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -447,7 +455,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -457,13 +465,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -477,7 +483,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -496,7 +502,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -517,7 +523,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -541,13 +547,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -629,7 +633,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 633 "quote_calc.tab.c" +#line 637 "quote_calc.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -647,19 +651,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -672,16 +674,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc.tab.h b/contrib/byacc/test/yacc/quote_calc.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc.tab.h rename to contrib/byacc/test/yacc/quote_calc.tab.h diff --git a/contrib/byacc/test/yacc/quote_calc2-s.error b/contrib/byacc/test/yacc/quote_calc2-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc2-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc2-s.output b/contrib/byacc/test/yacc/quote_calc2-s.output similarity index 100% rename from contrib/byacc/test/quote_calc2-s.output rename to contrib/byacc/test/yacc/quote_calc2-s.output diff --git a/contrib/byacc/test/quote_calc2-s.tab.c b/contrib/byacc/test/yacc/quote_calc2-s.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc2-s.tab.c rename to contrib/byacc/test/yacc/quote_calc2-s.tab.c index 4165df114..47b8fd0d3 100644 --- a/contrib/byacc/test/quote_calc2-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc2-s.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc2_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc2-s.tab.c" +#line 111 "quote_calc2-s.tab.c" -#ifndef YYSTYPE +#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 */ @@ -152,40 +156,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc2_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc2_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc2_len[] = { 2, +static const YYINT quote_calc2_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc2_defred[] = { 1, +static const YYINT quote_calc2_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc2_dgoto[] = { 1, +static const YYINT quote_calc2_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc2_sindex[] = { 0, +static const YYINT quote_calc2_sindex[] = { 0, -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc2_rindex[] = { 0, +static const YYINT quote_calc2_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc2_gindex[] = { 0, +static const YYINT quote_calc2_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 259 -static const short quote_calc2_table[] = { 16, +static const YYINT quote_calc2_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, @@ -213,7 +218,7 @@ static const short quote_calc2_table[] = { 16, 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc2_check[] = { 10, +static const YYINT quote_calc2_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, @@ -246,8 +251,10 @@ static const short quote_calc2_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc2_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, @@ -257,9 +264,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc2_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -299,18 +307,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -357,7 +365,7 @@ yylex(void) { } return( c ); } -#line 361 "quote_calc2-s.tab.c" +#line 369 "quote_calc2-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -371,27 +379,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -441,7 +449,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -451,13 +459,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -471,7 +477,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -490,7 +496,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -511,7 +517,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -535,13 +541,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -623,7 +627,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 627 "quote_calc2-s.tab.c" +#line 631 "quote_calc2-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -641,19 +645,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -666,16 +668,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc2-s.tab.h b/contrib/byacc/test/yacc/quote_calc2-s.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc2-s.tab.h rename to contrib/byacc/test/yacc/quote_calc2-s.tab.h diff --git a/contrib/byacc/test/yacc/quote_calc2.error b/contrib/byacc/test/yacc/quote_calc2.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc2.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc2.output b/contrib/byacc/test/yacc/quote_calc2.output similarity index 100% rename from contrib/byacc/test/quote_calc2.output rename to contrib/byacc/test/yacc/quote_calc2.output diff --git a/contrib/byacc/test/quote_calc2.tab.c b/contrib/byacc/test/yacc/quote_calc2.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc2.tab.c rename to contrib/byacc/test/yacc/quote_calc2.tab.c index 159954aaf..cdf8171f0 100644 --- a/contrib/byacc/test/quote_calc2.tab.c +++ b/contrib/byacc/test/yacc/quote_calc2.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc2_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc2.tab.c" +#line 111 "quote_calc2.tab.c" -#ifndef YYSTYPE +#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 */ @@ -158,40 +162,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc2_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc2_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc2_len[] = { 2, +static const YYINT quote_calc2_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc2_defred[] = { 1, +static const YYINT quote_calc2_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc2_dgoto[] = { 1, +static const YYINT quote_calc2_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc2_sindex[] = { 0, +static const YYINT quote_calc2_sindex[] = { 0, -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc2_rindex[] = { 0, +static const YYINT quote_calc2_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc2_gindex[] = { 0, +static const YYINT quote_calc2_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 259 -static const short quote_calc2_table[] = { 16, +static const YYINT quote_calc2_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, @@ -219,7 +224,7 @@ static const short quote_calc2_table[] = { 16, 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc2_check[] = { 10, +static const YYINT quote_calc2_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, @@ -252,8 +257,10 @@ static const short quote_calc2_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc2_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, @@ -263,9 +270,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc2_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -305,18 +313,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -363,7 +371,7 @@ yylex(void) { } return( c ); } -#line 367 "quote_calc2.tab.c" +#line 375 "quote_calc2.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -377,27 +385,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -447,7 +455,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -457,13 +465,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -477,7 +483,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -496,7 +502,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -517,7 +523,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -541,13 +547,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -629,7 +633,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 633 "quote_calc2.tab.c" +#line 637 "quote_calc2.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -647,19 +651,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -672,16 +674,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc2.tab.h b/contrib/byacc/test/yacc/quote_calc2.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc2.tab.h rename to contrib/byacc/test/yacc/quote_calc2.tab.h diff --git a/contrib/byacc/test/yacc/quote_calc3-s.error b/contrib/byacc/test/yacc/quote_calc3-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc3-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc3-s.output b/contrib/byacc/test/yacc/quote_calc3-s.output similarity index 100% rename from contrib/byacc/test/quote_calc3-s.output rename to contrib/byacc/test/yacc/quote_calc3-s.output diff --git a/contrib/byacc/test/quote_calc3-s.tab.c b/contrib/byacc/test/yacc/quote_calc3-s.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc3-s.tab.c rename to contrib/byacc/test/yacc/quote_calc3-s.tab.c index 480224a33..b91c1a14a 100644 --- a/contrib/byacc/test/quote_calc3-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc3-s.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc3_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc3-s.tab.c" +#line 111 "quote_calc3-s.tab.c" -#ifndef YYSTYPE +#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 */ @@ -152,40 +156,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc3_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc3_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc3_len[] = { 2, +static const YYINT quote_calc3_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc3_defred[] = { 1, +static const YYINT quote_calc3_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc3_dgoto[] = { 1, +static const YYINT quote_calc3_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc3_sindex[] = { 0, +static const YYINT quote_calc3_sindex[] = { 0, -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc3_rindex[] = { 0, +static const YYINT quote_calc3_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc3_gindex[] = { 0, +static const YYINT quote_calc3_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 258 -static const short quote_calc3_table[] = { 16, +static const YYINT quote_calc3_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, @@ -213,7 +218,7 @@ static const short quote_calc3_table[] = { 16, 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc3_check[] = { 10, +static const YYINT quote_calc3_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, @@ -246,8 +251,10 @@ static const short quote_calc3_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc3_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, @@ -258,9 +265,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", "\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", -"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",0,0,0,0,0, +"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc3_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -300,18 +308,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -358,7 +366,7 @@ yylex(void) { } return( c ); } -#line 362 "quote_calc3-s.tab.c" +#line 370 "quote_calc3-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -372,27 +380,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -442,7 +450,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -452,13 +460,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -472,7 +478,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -491,7 +497,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -512,7 +518,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -536,13 +542,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -624,7 +628,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 628 "quote_calc3-s.tab.c" +#line 632 "quote_calc3-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -642,19 +646,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -667,16 +669,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc3-s.tab.h b/contrib/byacc/test/yacc/quote_calc3-s.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc3-s.tab.h rename to contrib/byacc/test/yacc/quote_calc3-s.tab.h diff --git a/contrib/byacc/test/yacc/quote_calc3.error b/contrib/byacc/test/yacc/quote_calc3.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc3.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc3.output b/contrib/byacc/test/yacc/quote_calc3.output similarity index 100% rename from contrib/byacc/test/quote_calc3.output rename to contrib/byacc/test/yacc/quote_calc3.output diff --git a/contrib/byacc/test/quote_calc3.tab.c b/contrib/byacc/test/yacc/quote_calc3.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc3.tab.c rename to contrib/byacc/test/yacc/quote_calc3.tab.c index 1ab2ef0e5..ad4fe1ae6 100644 --- a/contrib/byacc/test/quote_calc3.tab.c +++ b/contrib/byacc/test/yacc/quote_calc3.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc3_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc3.tab.c" +#line 111 "quote_calc3.tab.c" -#ifndef YYSTYPE +#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 */ @@ -152,40 +156,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc3_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc3_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc3_len[] = { 2, +static const YYINT quote_calc3_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc3_defred[] = { 1, +static const YYINT quote_calc3_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc3_dgoto[] = { 1, +static const YYINT quote_calc3_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc3_sindex[] = { 0, +static const YYINT quote_calc3_sindex[] = { 0, -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc3_rindex[] = { 0, +static const YYINT quote_calc3_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc3_gindex[] = { 0, +static const YYINT quote_calc3_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 258 -static const short quote_calc3_table[] = { 16, +static const YYINT quote_calc3_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, @@ -213,7 +218,7 @@ static const short quote_calc3_table[] = { 16, 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc3_check[] = { 10, +static const YYINT quote_calc3_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, @@ -246,8 +251,10 @@ static const short quote_calc3_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc3_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, @@ -258,9 +265,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", "\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", -"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",0,0,0,0,0, +"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc3_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -300,18 +308,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -358,7 +366,7 @@ yylex(void) { } return( c ); } -#line 362 "quote_calc3.tab.c" +#line 370 "quote_calc3.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -372,27 +380,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -442,7 +450,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -452,13 +460,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -472,7 +478,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -491,7 +497,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -512,7 +518,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -536,13 +542,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -624,7 +628,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 628 "quote_calc3.tab.c" +#line 632 "quote_calc3.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -642,19 +646,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -667,16 +669,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc3.tab.h b/contrib/byacc/test/yacc/quote_calc3.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc3.tab.h rename to contrib/byacc/test/yacc/quote_calc3.tab.h diff --git a/contrib/byacc/test/yacc/quote_calc4-s.error b/contrib/byacc/test/yacc/quote_calc4-s.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc4-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc4-s.output b/contrib/byacc/test/yacc/quote_calc4-s.output similarity index 100% rename from contrib/byacc/test/quote_calc4-s.output rename to contrib/byacc/test/yacc/quote_calc4-s.output diff --git a/contrib/byacc/test/quote_calc4-s.tab.c b/contrib/byacc/test/yacc/quote_calc4-s.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc4-s.tab.c rename to contrib/byacc/test/yacc/quote_calc4-s.tab.c index 3e522f233..4d1e3d437 100644 --- a/contrib/byacc/test/quote_calc4-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc4-s.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc4_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc4-s.tab.c" +#line 111 "quote_calc4-s.tab.c" -#ifndef YYSTYPE +#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 */ @@ -152,40 +156,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc4_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc4_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc4_len[] = { 2, +static const YYINT quote_calc4_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc4_defred[] = { 1, +static const YYINT quote_calc4_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc4_dgoto[] = { 1, +static const YYINT quote_calc4_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc4_sindex[] = { 0, +static const YYINT quote_calc4_sindex[] = { 0, -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc4_rindex[] = { 0, +static const YYINT quote_calc4_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc4_gindex[] = { 0, +static const YYINT quote_calc4_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 259 -static const short quote_calc4_table[] = { 16, +static const YYINT quote_calc4_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, @@ -213,7 +218,7 @@ static const short quote_calc4_table[] = { 16, 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc4_check[] = { 10, +static const YYINT quote_calc4_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, @@ -246,8 +251,10 @@ static const short quote_calc4_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc4_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, @@ -258,9 +265,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", "\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", -"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",0,0,0,0,0, +"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc4_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -300,18 +308,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -358,7 +366,7 @@ yylex(void) { } return( c ); } -#line 362 "quote_calc4-s.tab.c" +#line 370 "quote_calc4-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -372,27 +380,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -442,7 +450,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -452,13 +460,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -472,7 +478,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -491,7 +497,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -512,7 +518,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -536,13 +542,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -624,7 +628,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 628 "quote_calc4-s.tab.c" +#line 632 "quote_calc4-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -642,19 +646,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -667,16 +669,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc4-s.tab.h b/contrib/byacc/test/yacc/quote_calc4-s.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc4-s.tab.h rename to contrib/byacc/test/yacc/quote_calc4-s.tab.h diff --git a/contrib/byacc/test/yacc/quote_calc4.error b/contrib/byacc/test/yacc/quote_calc4.error new file mode 100644 index 000000000..729d01c0a --- /dev/null +++ b/contrib/byacc/test/yacc/quote_calc4.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/contrib/byacc/test/quote_calc4.output b/contrib/byacc/test/yacc/quote_calc4.output similarity index 100% rename from contrib/byacc/test/quote_calc4.output rename to contrib/byacc/test/yacc/quote_calc4.output diff --git a/contrib/byacc/test/quote_calc4.tab.c b/contrib/byacc/test/yacc/quote_calc4.tab.c similarity index 88% rename from contrib/byacc/test/quote_calc4.tab.c rename to contrib/byacc/test/yacc/quote_calc4.tab.c index ca08d7761..a5f047ec8 100644 --- a/contrib/byacc/test/quote_calc4.tab.c +++ b/contrib/byacc/test/yacc/quote_calc4.tab.c @@ -1,16 +1,18 @@ -#ifndef lint -static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif +/* 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 quote_calc4_parse @@ -105,10 +107,12 @@ int base; int yylex(void); static void yyerror(const char *s); -#line 109 "quote_calc4.tab.c" +#line 111 "quote_calc4.tab.c" -#ifndef YYSTYPE +#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 */ @@ -152,40 +156,41 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -static const short quote_calc4_lhs[] = { -1, +typedef short YYINT; +static const YYINT quote_calc4_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; -static const short quote_calc4_len[] = { 2, +static const YYINT quote_calc4_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; -static const short quote_calc4_defred[] = { 1, +static const YYINT quote_calc4_defred[] = { 1, 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; -static const short quote_calc4_dgoto[] = { 1, +static const YYINT quote_calc4_dgoto[] = { 1, 7, 8, 9, }; -static const short quote_calc4_sindex[] = { 0, +static const YYINT quote_calc4_sindex[] = { 0, -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, -121, -243, }; -static const short quote_calc4_rindex[] = { 0, +static const YYINT quote_calc4_rindex[] = { 0, 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, 3, -4, }; -static const short quote_calc4_gindex[] = { 0, +static const YYINT quote_calc4_gindex[] = { 0, 0, 42, 0, }; #define YYTABLESIZE 259 -static const short quote_calc4_table[] = { 16, +static const YYINT quote_calc4_table[] = { 16, 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, @@ -213,7 +218,7 @@ static const short quote_calc4_table[] = { 16, 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, 16, 15, }; -static const short quote_calc4_check[] = { 10, +static const YYINT quote_calc4_check[] = { 10, 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, @@ -246,8 +251,10 @@ static const short quote_calc4_check[] = { 10, #define YYDEBUG 0 #endif #define YYMAXTOKEN 271 +#define YYUNDFTOKEN 277 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG -static const char *yyname[] = { +static const char *const quote_calc4_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, @@ -258,9 +265,10 @@ static const char *yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", "\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", -"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS", +"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",0,0,0,0,0, +"illegal-symbol", }; -static const char *yyrule[] = { +static const char *const quote_calc4_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", @@ -300,18 +308,18 @@ YYSTYPE yylval; #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 #endif #endif -#define YYINITSTACKSIZE 500 +#define YYINITSTACKSIZE 200 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; } YYSTACKDATA; @@ -358,7 +366,7 @@ yylex(void) { } return( c ); } -#line 362 "quote_calc4.tab.c" +#line 370 "quote_calc4.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -372,27 +380,27 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) - return -1; + return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) 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 -1; + return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) - return -1; + return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; @@ -442,7 +450,7 @@ YYPARSE_DECL() memset(&yystack, 0, sizeof(yystack)); #endif - if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; @@ -452,13 +460,11 @@ YYPARSE_DECL() if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -472,7 +478,7 @@ YYPARSE_DECL() printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -491,7 +497,7 @@ YYPARSE_DECL() } if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); + YYERROR_CALL("syntax error"); goto yyerrlab; @@ -512,7 +518,7 @@ YYPARSE_DECL() 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)) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) { goto yyoverflow; } @@ -536,13 +542,11 @@ YYPARSE_DECL() } else { - if (yychar == 0) goto yyabort; + if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } @@ -624,7 +628,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 628 "quote_calc4.tab.c" +#line 632 "quote_calc4.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; @@ -642,19 +646,17 @@ break; *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = YYLEX) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; + yys = yyname[YYTRANSLATE(yychar)]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yychar == 0) goto yyaccept; + if (yychar == YYEOF) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -667,16 +669,16 @@ break; 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)) + 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; goto yyloop; yyoverflow: - yyerror("yacc stack overflow"); + YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); diff --git a/contrib/byacc/test/quote_calc4.tab.h b/contrib/byacc/test/yacc/quote_calc4.tab.h similarity index 100% rename from contrib/byacc/test/quote_calc4.tab.h rename to contrib/byacc/test/yacc/quote_calc4.tab.h diff --git a/contrib/byacc/test/yacc/rename_debug.c b/contrib/byacc/test/yacc/rename_debug.c new file mode 100644 index 000000000..520207411 --- /dev/null +++ b/contrib/byacc/test/yacc/rename_debug.c @@ -0,0 +1,388 @@ +/* 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 +#line 17 "rename_debug.c" +#include "rename_debug.i" +#include "rename_debug.h" +typedef short YYINT; +static const YYINT yylhs[] = { -1, + 0, +}; +static const YYINT yylen[] = { 2, + 1, +}; +static const YYINT yydefred[] = { 0, + 1, 0, +}; +static const YYINT yydgoto[] = { 2, +}; +static const YYINT yysindex[] = { -256, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, +}; +static const YYINT yygindex[] = { 0, +}; +#define YYTABLESIZE 0 +static const YYINT yytable[] = { 1, +}; +static const YYINT yycheck[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif +#define YYMAXTOKEN 256 +#define YYUNDFTOKEN 259 +#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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : S", +"S : error", + +}; +#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; + 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 12 "code_debug.y" + +#include + +#ifdef YYBYACC +extern int YYLEX_DECL(); +#endif + +int +main(void) +{ + printf("yyparse() = %d\n", yyparse()); + return 0; +} + +int +yylex(void) +{ + return -1; +} + +static void +yyerror(const char* s) +{ + printf("%s\n", s); +} +#line 130 "rename_debug.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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) + { + } + 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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/rename_debug.error b/contrib/byacc/test/yacc/rename_debug.error new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/byacc/test/yacc/rename_debug.h b/contrib/byacc/test/yacc/rename_debug.h new file mode 100644 index 000000000..e1d14cbda --- /dev/null +++ b/contrib/byacc/test/yacc/rename_debug.h @@ -0,0 +1 @@ +#define YYERRCODE 256 diff --git a/contrib/byacc/test/yacc/rename_debug.i b/contrib/byacc/test/yacc/rename_debug.i new file mode 100644 index 000000000..b7b801439 --- /dev/null +++ b/contrib/byacc/test/yacc/rename_debug.i @@ -0,0 +1,56 @@ +#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; diff --git a/contrib/byacc/test/yacc/rename_debug.output b/contrib/byacc/test/yacc/rename_debug.output new file mode 100644 index 000000000..0c4db6225 --- /dev/null +++ b/contrib/byacc/test/yacc/rename_debug.output @@ -0,0 +1,27 @@ + 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 diff --git a/contrib/byacc/test/yacc/varsyntax_calc1.error b/contrib/byacc/test/yacc/varsyntax_calc1.error new file mode 100644 index 000000000..9c1f7152c --- /dev/null +++ b/contrib/byacc/test/yacc/varsyntax_calc1.error @@ -0,0 +1,2 @@ +YACC: 2 rules never reduced +YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/contrib/byacc/test/yacc/varsyntax_calc1.output b/contrib/byacc/test/yacc/varsyntax_calc1.output new file mode 100644 index 000000000..2b628d47d --- /dev/null +++ b/contrib/byacc/test/yacc/varsyntax_calc1.output @@ -0,0 +1,877 @@ + 0 $accept : line $end + + 1 lines : + 2 | lines line + + 3 line : dexp '\n' + 4 | vexp '\n' + 5 | DREG '=' dexp '\n' + 6 | VREG '=' vexp '\n' + 7 | error '\n' + + 8 dexp : CONST + 9 | DREG + 10 | dexp '+' dexp + 11 | dexp '-' dexp + 12 | dexp '*' dexp + 13 | dexp '/' dexp + 14 | '-' dexp + 15 | '(' dexp ')' + + 16 vexp : dexp + 17 | '(' dexp ',' dexp ')' + 18 | VREG + 19 | vexp '+' vexp + 20 | dexp '+' vexp + 21 | vexp '-' vexp + 22 | dexp '-' vexp + 23 | vexp '*' vexp + 24 | dexp '*' vexp + 25 | vexp '/' vexp + 26 | dexp '/' vexp + 27 | '-' vexp + 28 | '(' vexp ')' + +state 0 + $accept : . line $end (0) + + error shift 1 + DREG shift 2 + VREG shift 3 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + line goto 7 + dexp goto 8 + vexp goto 9 + + +state 1 + line : error . '\n' (7) + + '\n' shift 10 + . error + + +state 2 + line : DREG . '=' dexp '\n' (5) + dexp : DREG . (9) + + '=' shift 11 + '+' reduce 9 + '-' reduce 9 + '*' reduce 9 + '/' reduce 9 + '\n' reduce 9 + + +state 3 + line : VREG . '=' vexp '\n' (6) + vexp : VREG . (18) + + '=' shift 12 + '+' reduce 18 + '-' reduce 18 + '*' reduce 18 + '/' reduce 18 + '\n' reduce 18 + + +state 4 + dexp : CONST . (8) + + . reduce 8 + + +state 5 + dexp : '-' . dexp (14) + vexp : '-' . vexp (27) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 15 + vexp goto 16 + + +state 6 + dexp : '(' . dexp ')' (15) + vexp : '(' . dexp ',' dexp ')' (17) + vexp : '(' . vexp ')' (28) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 17 + vexp goto 18 + + +state 7 + $accept : line . $end (0) + + $end accept + + +8: shift/reduce conflict (shift 19, reduce 16) on '+' +8: shift/reduce conflict (shift 20, reduce 16) on '-' +8: shift/reduce conflict (shift 21, reduce 16) on '*' +8: shift/reduce conflict (shift 22, reduce 16) on '/' +8: shift/reduce conflict (shift 23, reduce 16) on '\n' +state 8 + line : dexp . '\n' (3) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + '\n' shift 23 + + +state 9 + line : vexp . '\n' (4) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' shift 28 + . error + + +state 10 + line : error '\n' . (7) + + . reduce 7 + + +state 11 + line : DREG '=' . dexp '\n' (5) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 31 + + +state 12 + line : VREG '=' . vexp '\n' (6) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 33 + + +state 13 + dexp : DREG . (9) + + . reduce 9 + + +state 14 + vexp : VREG . (18) + + . reduce 18 + + +15: reduce/reduce conflict (reduce 14, reduce 16) on '+' +15: reduce/reduce conflict (reduce 14, reduce 16) on '-' +15: reduce/reduce conflict (reduce 14, reduce 16) on '*' +15: reduce/reduce conflict (reduce 14, reduce 16) on '/' +15: reduce/reduce conflict (reduce 14, reduce 16) on '\n' +15: reduce/reduce conflict (reduce 14, reduce 16) on ')' +state 15 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 14 + + +state 16 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '-' vexp . (27) + + . reduce 27 + + +17: shift/reduce conflict (shift 19, reduce 16) on '+' +17: shift/reduce conflict (shift 20, reduce 16) on '-' +17: shift/reduce conflict (shift 21, reduce 16) on '*' +17: shift/reduce conflict (shift 22, reduce 16) on '/' +17: shift/reduce conflict (shift 34, reduce 16) on ')' +state 17 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + vexp : dexp . (16) + vexp : '(' dexp . ',' dexp ')' (17) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + ')' shift 34 + ',' shift 35 + + +state 18 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : '(' vexp . ')' (28) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + ')' shift 36 + . error + + +state 19 + dexp : dexp '+' . dexp (10) + vexp : dexp '+' . vexp (20) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 37 + vexp goto 38 + + +state 20 + dexp : dexp '-' . dexp (11) + vexp : dexp '-' . vexp (22) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 39 + vexp goto 40 + + +state 21 + dexp : dexp '*' . dexp (12) + vexp : dexp '*' . vexp (24) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 41 + vexp goto 42 + + +state 22 + dexp : dexp '/' . dexp (13) + vexp : dexp '/' . vexp (26) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 43 + vexp goto 44 + + +state 23 + line : dexp '\n' . (3) + + . reduce 3 + + +state 24 + vexp : vexp '+' . vexp (19) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 45 + + +state 25 + vexp : vexp '-' . vexp (21) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 46 + + +state 26 + vexp : vexp '*' . vexp (23) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 47 + + +state 27 + vexp : vexp '/' . vexp (25) + + DREG shift 13 + VREG shift 14 + CONST shift 4 + '-' shift 5 + '(' shift 6 + . error + + dexp goto 32 + vexp goto 48 + + +state 28 + line : vexp '\n' . (4) + + . reduce 4 + + +state 29 + dexp : '-' . dexp (14) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 49 + + +state 30 + dexp : '(' . dexp ')' (15) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 50 + + +state 31 + line : DREG '=' dexp . '\n' (5) + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + '\n' shift 55 + . error + + +32: shift/reduce conflict (shift 19, reduce 16) on '+' +32: shift/reduce conflict (shift 20, reduce 16) on '-' +32: shift/reduce conflict (shift 21, reduce 16) on '*' +32: shift/reduce conflict (shift 22, reduce 16) on '/' +state 32 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '+' shift 19 + '-' shift 20 + '*' shift 21 + '/' shift 22 + '\n' reduce 16 + ')' reduce 16 + + +state 33 + line : VREG '=' vexp . '\n' (6) + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '+' shift 24 + '-' shift 25 + '*' shift 26 + '/' shift 27 + '\n' shift 56 + . error + + +state 34 + dexp : '(' dexp ')' . (15) + + . reduce 15 + + +state 35 + vexp : '(' dexp ',' . dexp ')' (17) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 57 + + +state 36 + vexp : '(' vexp ')' . (28) + + . reduce 28 + + +37: reduce/reduce conflict (reduce 10, reduce 16) on '+' +37: reduce/reduce conflict (reduce 10, reduce 16) on '-' +37: shift/reduce conflict (shift 21, reduce 16) on '*' +37: shift/reduce conflict (shift 22, reduce 16) on '/' +37: reduce/reduce conflict (reduce 10, reduce 16) on '\n' +37: reduce/reduce conflict (reduce 10, reduce 16) on ')' +state 37 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' shift 21 + '/' shift 22 + '+' reduce 10 + '-' reduce 10 + '\n' reduce 10 + ')' reduce 10 + ',' reduce 10 + + +state 38 + vexp : vexp . '+' vexp (19) + vexp : dexp '+' vexp . (20) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 20 + '-' reduce 20 + '\n' reduce 20 + ')' reduce 20 + + +39: reduce/reduce conflict (reduce 11, reduce 16) on '+' +39: reduce/reduce conflict (reduce 11, reduce 16) on '-' +39: shift/reduce conflict (shift 21, reduce 16) on '*' +39: shift/reduce conflict (shift 22, reduce 16) on '/' +39: reduce/reduce conflict (reduce 11, reduce 16) on '\n' +39: reduce/reduce conflict (reduce 11, reduce 16) on ')' +state 39 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + '*' shift 21 + '/' shift 22 + '+' reduce 11 + '-' reduce 11 + '\n' reduce 11 + ')' reduce 11 + ',' reduce 11 + + +state 40 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : dexp '-' vexp . (22) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 22 + '-' reduce 22 + '\n' reduce 22 + ')' reduce 22 + + +41: reduce/reduce conflict (reduce 12, reduce 16) on '+' +41: reduce/reduce conflict (reduce 12, reduce 16) on '-' +41: reduce/reduce conflict (reduce 12, reduce 16) on '*' +41: reduce/reduce conflict (reduce 12, reduce 16) on '/' +41: reduce/reduce conflict (reduce 12, reduce 16) on '\n' +41: reduce/reduce conflict (reduce 12, reduce 16) on ')' +state 41 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 12 + + +state 42 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : dexp '*' vexp . (24) + vexp : vexp . '/' vexp (25) + + . reduce 24 + + +43: reduce/reduce conflict (reduce 13, reduce 16) on '+' +43: reduce/reduce conflict (reduce 13, reduce 16) on '-' +43: reduce/reduce conflict (reduce 13, reduce 16) on '*' +43: reduce/reduce conflict (reduce 13, reduce 16) on '/' +43: reduce/reduce conflict (reduce 13, reduce 16) on '\n' +43: reduce/reduce conflict (reduce 13, reduce 16) on ')' +state 43 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + vexp : dexp . (16) + vexp : dexp . '+' vexp (20) + vexp : dexp . '-' vexp (22) + vexp : dexp . '*' vexp (24) + vexp : dexp . '/' vexp (26) + + . reduce 13 + + +state 44 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : dexp '/' vexp . (26) + + . reduce 26 + + +state 45 + vexp : vexp . '+' vexp (19) + vexp : vexp '+' vexp . (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 19 + '-' reduce 19 + '\n' reduce 19 + ')' reduce 19 + + +state 46 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp '-' vexp . (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + + '*' shift 26 + '/' shift 27 + '+' reduce 21 + '-' reduce 21 + '\n' reduce 21 + ')' reduce 21 + + +state 47 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp '*' vexp . (23) + vexp : vexp . '/' vexp (25) + + . reduce 23 + + +state 48 + vexp : vexp . '+' vexp (19) + vexp : vexp . '-' vexp (21) + vexp : vexp . '*' vexp (23) + vexp : vexp . '/' vexp (25) + vexp : vexp '/' vexp . (25) + + . reduce 25 + + +state 49 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '-' dexp . (14) + + . reduce 14 + + +state 50 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : '(' dexp . ')' (15) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 34 + . error + + +state 51 + dexp : dexp '+' . dexp (10) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 58 + + +state 52 + dexp : dexp '-' . dexp (11) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 59 + + +state 53 + dexp : dexp '*' . dexp (12) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 60 + + +state 54 + dexp : dexp '/' . dexp (13) + + DREG shift 13 + CONST shift 4 + '-' shift 29 + '(' shift 30 + . error + + dexp goto 61 + + +state 55 + line : DREG '=' dexp '\n' . (5) + + . reduce 5 + + +state 56 + line : VREG '=' vexp '\n' . (6) + + . reduce 6 + + +state 57 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + vexp : '(' dexp ',' dexp . ')' (17) + + '+' shift 51 + '-' shift 52 + '*' shift 53 + '/' shift 54 + ')' shift 62 + . error + + +state 58 + dexp : dexp . '+' dexp (10) + dexp : dexp '+' dexp . (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 10 + '-' reduce 10 + '\n' reduce 10 + ')' reduce 10 + + +state 59 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp '-' dexp . (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + + '*' shift 53 + '/' shift 54 + '+' reduce 11 + '-' reduce 11 + '\n' reduce 11 + ')' reduce 11 + + +state 60 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp '*' dexp . (12) + dexp : dexp . '/' dexp (13) + + . reduce 12 + + +state 61 + dexp : dexp . '+' dexp (10) + dexp : dexp . '-' dexp (11) + dexp : dexp . '*' dexp (12) + dexp : dexp . '/' dexp (13) + dexp : dexp '/' dexp . (13) + + . reduce 13 + + +state 62 + vexp : '(' dexp ',' dexp ')' . (17) + + . reduce 17 + + +Rules never reduced: + lines : (1) + lines : lines line (2) + + +State 8 contains 5 shift/reduce conflicts. +State 15 contains 6 reduce/reduce conflicts. +State 17 contains 5 shift/reduce conflicts. +State 32 contains 4 shift/reduce conflicts. +State 37 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 39 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts. +State 41 contains 6 reduce/reduce conflicts. +State 43 contains 6 reduce/reduce conflicts. + + +15 terminals, 5 nonterminals +29 grammar rules, 63 states diff --git a/contrib/byacc/test/yacc/varsyntax_calc1.tab.c b/contrib/byacc/test/yacc/varsyntax_calc1.tab.c new file mode 100644 index 000000000..49a152781 --- /dev/null +++ b/contrib/byacc/test/yacc/varsyntax_calc1.tab.c @@ -0,0 +1,915 @@ +/* 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 +#ident "check variant syntax features" + +#ifndef yyparse +#define yyparse varsyntax_calc1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex varsyntax_calc1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror varsyntax_calc1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar varsyntax_calc1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval varsyntax_calc1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval varsyntax_calc1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug varsyntax_calc1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs varsyntax_calc1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag varsyntax_calc1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs varsyntax_calc1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen varsyntax_calc1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred varsyntax_calc1_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto varsyntax_calc1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex varsyntax_calc1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex varsyntax_calc1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex varsyntax_calc1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable varsyntax_calc1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck varsyntax_calc1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname varsyntax_calc1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule varsyntax_calc1_rule +#endif /* yyrule */ +#define YYPREFIX "varsyntax_calc1_" + +#define YYPURE 0 + +#line 3 "varsyntax_calc1.y" + +/* http://dinosaur.compilertools.net/yacc/index.html * /*/ + +#include +#include +#include +#include + +typedef struct interval +{ + double lo, hi; +} +INTERVAL; + +INTERVAL vmul(double, double, INTERVAL); +INTERVAL vdiv(double, double, INTERVAL); + +extern int yylex(void); +static void yyerror(const char *s); + +int dcheck(INTERVAL); + +double dreg[26]; +INTERVAL vreg[26]; + +#line 32 "varsyntax_calc1.y" +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; /* dreg & vreg array index values*/ + double dval; /* floating point values*/ + INTERVAL vval; /* interval values*/ +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 142 "varsyntax_calc1.tab.c" + +/* 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 DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#define YYERRCODE 256 +typedef short YYINT; +static const YYINT varsyntax_calc1_lhs[] = { -1, + 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, +}; +static const YYINT varsyntax_calc1_len[] = { 2, + 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, + 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 3, +}; +static const YYINT varsyntax_calc1_defred[] = { 0, + 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, + 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, + 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, + 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, + 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, + 13, 17, +}; +static const YYINT varsyntax_calc1_dgoto[] = { 7, + 32, 9, 0, +}; +static const YYINT varsyntax_calc1_sindex[] = { -40, + -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, + -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, + -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, + 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, + 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, + -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, + 0, 0, +}; +static const YYINT varsyntax_calc1_rindex[] = { 0, + 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, + 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, + 0, 0, +}; +static const YYINT varsyntax_calc1_gindex[] = { 0, + 4, 124, 0, +}; +#define YYTABLESIZE 225 +static const YYINT varsyntax_calc1_table[] = { 6, + 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, + 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, + 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, + 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, + 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, + 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, + 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, + 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, + 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, + 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, + 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, + 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, + 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, + 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, + 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, + 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, + 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, + 14, 4, 13, 0, 4, +}; +static const YYINT varsyntax_calc1_check[] = { 40, + 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, + 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, + -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, + 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, + 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, + -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, + 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, + 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, + 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, + 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, + 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, + 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, + 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, + 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, + -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, + 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, + 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, + -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -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, 259, 257, + 258, 259, 257, -1, 259, +}; +#define YYFINAL 7 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 260 +#define YYUNDFTOKEN 266 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const varsyntax_calc1_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, +0,0,"DREG","VREG","CONST","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const varsyntax_calc1_rule[] = { +"$accept : line", +"lines :", +"lines : lines line", +"line : dexp '\\n'", +"line : vexp '\\n'", +"line : DREG '=' dexp '\\n'", +"line : VREG '=' vexp '\\n'", +"line : error '\\n'", +"dexp : CONST", +"dexp : DREG", +"dexp : dexp '+' dexp", +"dexp : dexp '-' dexp", +"dexp : dexp '*' dexp", +"dexp : dexp '/' dexp", +"dexp : '-' dexp", +"dexp : '(' dexp ')'", +"vexp : dexp", +"vexp : '(' dexp ',' dexp ')'", +"vexp : VREG", +"vexp : vexp '+' vexp", +"vexp : dexp '+' vexp", +"vexp : vexp '-' vexp", +"vexp : dexp '-' vexp", +"vexp : vexp '*' vexp", +"vexp : dexp '*' vexp", +"vexp : vexp '/' vexp", +"vexp : dexp '/' vexp", +"vexp : '-' vexp", +"vexp : '(' vexp ')'", + +}; +#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; + 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 178 "varsyntax_calc1.y" + /* beginning of subroutines section */ + +#define BSZ 50 /* buffer size for floating point numbers */ + + /* lexical analysis */ + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + int c; + + while ((c = getchar()) == ' ') + { /* skip over blanks */ + } + + if (isupper(c)) + { + yylval.ival = c - 'A'; + return (VREG); + } + if (islower(c)) + { + yylval.ival = c - 'a'; + return (DREG); + } + + if (isdigit(c) || c == '.') + { + /* gobble up digits, points, exponents */ + char buf[BSZ + 1], *cp = buf; + int dot = 0, expr = 0; + + for (; (cp - buf) < BSZ; ++cp, c = getchar()) + { + + *cp = (char) c; + if (isdigit(c)) + continue; + if (c == '.') + { + if (dot++ || expr) + return ('.'); /* will cause syntax error */ + continue; + } + + if (c == 'e') + { + if (expr++) + return ('e'); /* will cause syntax error */ + continue; + } + + /* end of number */ + break; + } + *cp = '\0'; + + if ((cp - buf) >= BSZ) + printf("constant too long: truncated\n"); + else + ungetc(c, stdin); /* push back last char read */ + yylval.dval = atof(buf); + return (CONST); + } + return (c); +} + +static INTERVAL +hilo(double a, double b, double c, double d) +{ + /* returns the smallest interval containing a, b, c, and d */ + /* used by *, / routines */ + INTERVAL v; + + if (a > b) + { + v.hi = a; + v.lo = b; + } + else + { + v.hi = b; + v.lo = a; + } + + if (c > d) + { + if (c > v.hi) + v.hi = c; + if (d < v.lo) + v.lo = d; + } + else + { + if (d > v.hi) + v.hi = d; + if (c < v.lo) + v.lo = c; + } + return (v); +} + +INTERVAL +vmul(double a, double b, INTERVAL v) +{ + return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); +} + +int +dcheck(INTERVAL v) +{ + if (v.hi >= 0. && v.lo <= 0.) + { + printf("divisor interval contains 0.\n"); + return (1); + } + return (0); +} + +INTERVAL +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" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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 + + 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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 59 "varsyntax_calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[-1].dval); + } +break; +case 4: +#line 63 "varsyntax_calc1.y" + { + (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); + } +break; +case 5: +#line 67 "varsyntax_calc1.y" + { + dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; + } +break; +case 6: +#line 71 "varsyntax_calc1.y" + { + vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; + } +break; +case 7: +#line 75 "varsyntax_calc1.y" + { + yyerrok; + } +break; +case 9: +#line 82 "varsyntax_calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ + } +break; +case 10: +#line 86 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +break; +case 11: +#line 90 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +break; +case 12: +#line 94 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +break; +case 13: +#line 98 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +break; +case 14: +#line 102 "varsyntax_calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +break; +case 15: +#line 106 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +break; +case 16: +#line 112 "varsyntax_calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +break; +case 17: +#line 116 "varsyntax_calc1.y" + { + yyval.vval.lo = yystack.l_mark[-3].dval; + yyval.vval.hi = yystack.l_mark[-1].dval; + if ( yyval.vval.lo > yyval.vval.hi ) + { + (void) printf("interval out of order\n"); + YYERROR; + } + } +break; +case 18: +#line 126 "varsyntax_calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +break; +case 19: +#line 130 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; + } +break; +case 20: +#line 135 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; + yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; + } +break; +case 21: +#line 140 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; + } +break; +case 22: +#line 145 "varsyntax_calc1.y" + { + yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; + yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; + } +break; +case 23: +#line 150 "varsyntax_calc1.y" + { + yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 24: +#line 154 "varsyntax_calc1.y" + { + yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 25: +#line 158 "varsyntax_calc1.y" + { + if (dcheck(yystack.l_mark[0].vval)) YYERROR; + yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); + } +break; +case 26: +#line 163 "varsyntax_calc1.y" + { + if (dcheck ( yystack.l_mark[0].vval )) YYERROR; + yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); + } +break; +case 27: +#line 168 "varsyntax_calc1.y" + { + yyval.vval.hi = -yystack.l_mark[0].vval.lo; + yyval.vval.lo = -yystack.l_mark[0].vval.hi; + } +break; +case 28: +#line 173 "varsyntax_calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +break; +#line 857 "varsyntax_calc1.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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/contrib/byacc/test/yacc/varsyntax_calc1.tab.h b/contrib/byacc/test/yacc/varsyntax_calc1.tab.h new file mode 100644 index 000000000..fd07f2cc3 --- /dev/null +++ b/contrib/byacc/test/yacc/varsyntax_calc1.tab.h @@ -0,0 +1,18 @@ +#define DREG 257 +#define VREG 258 +#define CONST 259 +#define UMINUS 260 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union +{ + int ival; /* dreg & vreg array index values*/ + double dval; /* floating point values*/ + INTERVAL vval; /* interval values*/ +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE varsyntax_calc1_lval; diff --git a/contrib/byacc/verbose.c b/contrib/byacc/verbose.c index 3e6ea2852..b4e110212 100644 --- a/contrib/byacc/verbose.c +++ b/contrib/byacc/verbose.c @@ -1,4 +1,4 @@ -/* $Id: verbose.c,v 1.10 2012/05/26 00:45:17 tom Exp $ */ +/* $Id: verbose.c,v 1.11 2014/04/01 23:15:59 Tom.Shields Exp $ */ #include "defs.h" @@ -13,7 +13,7 @@ static void print_shifts(action *p); static void print_state(int state); static void print_reductions(action *p, int defred2); -static short *null_rules; +static Value_t *null_rules; void verbose(void) @@ -23,7 +23,7 @@ verbose(void) if (!vflag) return; - null_rules = TMALLOC(short, nrules); + null_rules = TMALLOC(Value_t, nrules); NO_SPACE(null_rules); fprintf(verbose_file, "\f\n"); @@ -39,13 +39,33 @@ verbose(void) fprintf(verbose_file, "\n\n%d terminals, %d nonterminals\n", ntokens, nvars); fprintf(verbose_file, "%d grammar rules, %d states\n", nrules - 2, nstates); +#if defined(YYBTYACC) + { /* print out the grammar symbol # and parser internal symbol # for each + symbol as an aide to writing the implementation for YYDESTRUCT_CALL() + and YYSTYPE_TOSTRING() */ + int maxtok = 0; + + fputs("\ngrammar parser grammar\n", verbose_file); + fputs("symbol# value# symbol\n", verbose_file); + for (i = 0; i < ntokens; ++i) + { + fprintf(verbose_file, " %5d %5d %s\n", + i, symbol_value[i], symbol_name[i]); + if (symbol_value[i] > maxtok) + maxtok = symbol_value[i]; + } + for (i = ntokens; i < nsyms; ++i) + fprintf(verbose_file, " %5d %5d %s\n", + i, (maxtok + 1) + symbol_value[i] + 1, symbol_name[i]); + } +#endif } static void log_unused(void) { int i; - short *p; + Value_t *p; fprintf(verbose_file, "\n\nRules never reduced:\n"); for (i = 3; i < nrules; ++i) @@ -155,8 +175,8 @@ print_core(int state) int k; int rule; core *statep; - short *sp; - short *sp1; + Value_t *sp; + Value_t *sp1; statep = state_table[state]; k = statep->nitems; @@ -273,6 +293,11 @@ print_shifts(action *p) if (p->action_code == SHIFT && p->suppressed == 0) fprintf(verbose_file, "\t%s shift %d\n", symbol_name[p->symbol], p->number); +#if defined(YYBTYACC) + if (backtrack && p->action_code == SHIFT && p->suppressed == 1) + fprintf(verbose_file, "\t%s [trial] shift %d\n", + symbol_name[p->symbol], p->number); +#endif } } } @@ -305,6 +330,11 @@ print_reductions(action *p, int defred2) if (p->suppressed == 0) fprintf(verbose_file, "\t%s reduce %d\n", symbol_name[p->symbol], k); +#if defined(YYBTYACC) + if (backtrack && p->suppressed == 1) + fprintf(verbose_file, "\t%s [trial] reduce %d\n", + symbol_name[p->symbol], k); +#endif } } @@ -318,7 +348,7 @@ print_gotos(int stateno) { int i, k; int as; - short *to_state2; + Value_t *to_state2; shifts *sp; putc('\n', verbose_file); diff --git a/contrib/byacc/vmsbuild.com b/contrib/byacc/vmsbuild.com index 94b02c688..b57d26e48 100644 --- a/contrib/byacc/vmsbuild.com +++ b/contrib/byacc/vmsbuild.com @@ -1,4 +1,4 @@ -$! $Id: vmsbuild.com,v 1.1 2000/11/21 00:38:46 tom Exp $ +$! $Id: vmsbuild.com,v 1.2 2014/04/06 19:08:57 tom Exp $ $! VMS build-script for BYACC. Requires installed C compiler $! $! Screen Configurations @@ -70,7 +70,7 @@ $ write optf "lr0.obj" $ write optf "mkpar.obj" $ write optf "output.obj" $ write optf "reader.obj" -$ write optf "skeleton.obj" +$ write optf "yaccpar.obj" $ write optf "symtab.obj" $ write optf "verbose.obj" $ write optf "warshall.obj" @@ -138,7 +138,7 @@ $ call make main $ call make mkpar $ call make output $ call make reader -$ call make skeleton +$ call make yaccpar $ call make symtab $ call make verbose $ call make warshall diff --git a/contrib/byacc/yacc.1 b/contrib/byacc/yacc.1 index 239380a36..357426e78 100644 --- a/contrib/byacc/yacc.1 +++ b/contrib/byacc/yacc.1 @@ -1,4 +1,4 @@ -.\" $Id: yacc.1,v 1.18 2012/01/15 18:12:28 tom Exp $ +.\" $Id: yacc.1,v 1.23 2014/04/09 09:48:50 tom Exp $ .\" .\" .TH YACC 1 "July\ 15,\ 1990" .\" .UC 6 @@ -8,20 +8,29 @@ .sp .in +4 .. -.de EE +.de XE .in -4 .fi .. +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds AQ \(aq +.el .ds AQ ' +.ie \n(.g .ds `` \(lq +.el .ds `` `` +.ie \n(.g .ds '' \(rq +.el .ds '' '' .\" Bulleted paragraph .de bP .IP \(bu 4 .. -.TH YACC 1 "September 7, 2011" "Berkeley Yacc" "User Commands" +.TH YACC 1 "January 1, 2014" "Berkeley Yacc" "User Commands" .SH NAME Yacc \- an LALR(1) parser generator .SH SYNOPSIS -.B yacc [ -dgilrtv ] [ \-b +.B yacc [ -BdgilLPrtvVy ] [ \-b .I file_prefix +.B ] [ \-o +.I output_file .B ] [ \-p .I symbol_prefix .B ] @@ -48,6 +57,9 @@ the string denoted by The default prefix is the character .IR y. .TP +.B \-B +create a backtracking parser (compile-type configuration for \fBbtyacc\fP). +.TP .B \-d The \fB-d\fR option causes the header file .BR y.tab.h @@ -89,11 +101,14 @@ If the \fB-l\fR option is specified, will not insert the \fI#line\fP directives. \&\fI#line\fP directives specified by the user will be retained. .TP +.B \-L +enable position processing, e.g., \*(``%locations\*('' (compile-type configuration for \fBbtyacc\fP). +.TP \fB\-o \fP\fIoutput_file\fR specify the filename for the parser file. If this option is not given, the output filename is the file prefix concatenated with the file suffix, e.g., \fBy.tab.c\fP. -This overrides the \fB-p\fP option. +This overrides the \fB-b\fP option. .TP \fB\-p \fP\fIsymbol_prefix\fR The @@ -105,30 +120,31 @@ The default prefix is the string .BR yy. .TP .B \-P -create a reentrant parser, e.g., "%pure-parser". +create a reentrant parser, e.g., \*(``%pure-parser\*(''. .TP .B \-r The .B \-r option causes .B yacc -to produce separate files for code and tables. The code file -is named +to produce separate files for code and tables. +The code file is named .IR y.code.c, and the tables file is named .IR y.tab.c. -The prefix "\fIy.\fP" can be overridden using the \fB\-b\fP option. +The prefix \*(``\fIy.\fP\*('' can be overridden using the \fB\-b\fP option. .TP .B \-s -suppress "\fB#define\fP" statements generated for string literals in -a "\fB%token\fP" statement, to more closely match original \fByacc\fP behavior. +suppress \*(``\fB#define\fP\*('' statements generated for string literals in +a \*(``\fB%token\fP\*('' statement, +to more closely match original \fByacc\fP behavior. .IP Normally when \fByacc\fP sees a line such as .ES %token OP_ADD "ADD" -.EE +.XE .IP -it notices that the quoted "ADD" is a valid C identifier, +it notices that the quoted \*(``ADD\*('' is a valid C identifier, and generates a #define not only for OP_ADD, but for ADD as well, e.g., @@ -136,12 +152,13 @@ e.g., #define OP_ADD 257 .br #define ADD 258 -.EE +.XE .IP -The original \fByacc\fP does not generate the second "\fB#define\fP". -The \fB\-s\fP option suppresses this "\fB#define\fP". +The original \fByacc\fP does not generate the second \*(``\fB#define\fP\*(''. +The \fB\-s\fP option suppresses this \*(``\fB#define\fP\*(''. .IP -POSIX (IEEE 1003.1 2004) documents only names and numbers for "\fB%token\fP", +POSIX (IEEE 1003.1 2004) documents only names and numbers +for \*(``\fB%token\fP\*('', though original \fByacc\fP and bison also accept string literals. .TP .B \-t @@ -166,11 +183,56 @@ print the version number to the standard output. which bison supports for ostensible POSIX compatibility. .SH EXTENSIONS .B yacc -provides some extensions for compatibility with bison and other implementations -of yacc: +provides some extensions for +compatibility with bison and other implementations of yacc. +The \fB%destructor\fP and \fB%locations\fP features are available +only if \fByacc\fP has been configured and compiled to support the +back-tracking (\fBbtyacc\fP) functionality. +The remaining features are always available: +.TP +\fB %destructor\fP { \fIcode\fP } \fIsymbol+\fP +defines code that is invoked when a symbol is automatically +discarded during error recovery. +This code can be used to +reclaim dynamically allocated memory associated with the corresponding +semantic value for cases where user actions cannot manage the memory +explicitly. +.IP +On encountering a parse error, the generated parser +discards symbols on the stack and input tokens until it reaches a state +that will allow parsing to continue. +This error recovery approach results in a memory leak +if the \fBYYSTYPE\fP value is, or contains, +pointers to dynamically allocated memory. +.IP +The bracketed \fIcode\fP is invoked whenever the parser discards one of +the symbols. Within \fIcode\fP, \*(``\fB$$\fP\*('' or +\*(``\fB$$\fP\*('' designates the semantic value associated with the +discarded symbol, and \*(``\fB@$\fP\*('' designates its location (see +\fB%locations\fP directive). +.IP +A per-symbol destructor is defined by listing a grammar symbol +in \fIsymbol+\fP. A per-type destructor is defined by listing +a semantic type tag (e.g., \*(``\*('') in \fIsymbol+\fP; in this +case, the parser will invoke \fIcode\fP whenever it discards any grammar +symbol that has that semantic type tag, unless that symbol has its own +per-symbol destructor. +.IP +Two categories of default destructor are supported that are +invoked when discarding any grammar symbol that has no per-symbol and no +per-type destructor: +.RS +.bP +the code for \*(``\fB<*>\fP\*('' is used +for grammar symbols that have an explicitly declared semantic type tag +(via \*(``\fB%type\fP\*(''); +.bP +the code for \*(``\fB<>\fP\*('' is used +for grammar symbols that have no declared semantic type tag. +.RE .TP \fB %expect\fP \fInumber\fP -tell \fByacc\fP the expected number of shift/reduce conflicts. +tells \fByacc\fP the expected number of shift/reduce conflicts. That makes it only report the number if it differs. .TP \fB %expect-rr\fP \fInumber\fP @@ -178,6 +240,42 @@ tell \fByacc\fP the expected number of reduce/reduce conflicts. That makes it only report the number if it differs. This is (unlike bison) allowable in LALR parsers. .TP +\fB %locations\fP +tells \fByacc\fP to enable management of position information associated +with each token, provided by the lexer in the global variable \fByylloc\fP, +similar to management of semantic value information provided in \fByylval\fP. +.IP +As for semantic values, locations can be referenced within actions using +\fB@$\fP to refer to the location of the left hand side symbol, and \fB@N\fP +(\fBN\fP an integer) to refer to the location of one of the right hand side +symbols. Also as for semantic values, when a rule is matched, a default +action is used the compute the location represented by \fB@$\fP as the +beginning of the first symbol and the end of the last symbol in the right +hand side of the rule. This default computation can be overridden by +explicit assignment to \fB@$\fP in a rule action. +.IP +The type of \fByylloc\fP is \fBYYLTYPE\fP, which is defined by default as: +.ES +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +.XE +.IP +\fBYYLTYPE\fP can be redefined by the user +(\fBYYLTYPE_IS_DEFINED\fP must be defined, to inhibit the default) +in the declarations section of the specification file. +As in bison, the macro \fBYYLLOC_DEFAULT\fP is invoked +each time a rule is matched to calculate a position for the left hand side of +the rule, before the associated action is executed; this macro can be +redefined by the user. +.IP +This directive adds a \fBYYLTYPE\fP parameter to \fByyerror()\fP. +If the \fB%pure-parser\fP directive is present, +a \fBYYLTYPE\fP parameter is added to \fByylex()\fP calls. +.TP \fB %lex-param\fP { \fIargument-declaration\fP } By default, the lexer accepts no parameters, e.g., \fByylex()\fP. Use this directive to add parameter declarations for your customized lexer. @@ -190,6 +288,13 @@ Use this directive to add parameter declarations for your customized parser. Most variables (other than \fByydebug\fP and \fByynerrs\fP) are allocated on the stack within \fByyparse\fP, making the parser reasonably reentrant. +.TP +\fB %token-table\fP +Make the parser's names for tokens available in the \fByytname\fP array. +However, +.B yacc +does not predefine \*(``$end\*('', \*(``$error\*('' +or \*(``$undefined\*('' in this array. .SH PORTABILITY According to Robert Corbett, .ES @@ -198,17 +303,17 @@ as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input specification that conforms to the AT&T Yacc documentation. Specifications that take advantage of undocumented features of AT&T Yacc will probably be rejected. -.EE +.XE .PP The rationale in .ES http://pubs.opengroup.org/onlinepubs/9699919799/utilities/yacc.html -.EE +.XE .PP documents some features of AT&T yacc which are no longer required for POSIX compliance. .PP -That said, you may be interested in reusing grammary files with some +That said, you may be interested in reusing grammar files with some other implementation which is not strictly compatible with AT&T yacc. For instance, there is bison. Here are a few differences: @@ -220,19 +325,19 @@ of an action (as in the original grammar file \fBftp.y\fP): = { statcmd(); } -.EE +.XE .bP \fBYacc\fP and bison emit code in different order, and in particular bison makes forward reference to common functions such as yylex, yyparse and yyerror without providing prototypes. .bP -Bison's support for "%expect" is broken in more than one release. +Bison's support for \*(``%expect\*('' is broken in more than one release. For best results using bison, delete that directive. .bP Bison has no equivalent for some of \fByacc\fP's commmand-line options, relying on directives embedded in the grammar file. .bP -Bison's "\fB\-y\fP" option does not affect bison's lack of support for +Bison's \*(``\fB\-y\fP\*('' option does not affect bison's lack of support for features of AT&T yacc which were deemed obsolescent. . .SH DIAGNOSTICS diff --git a/contrib/byacc/skeleton.c b/contrib/byacc/yaccpar.c similarity index 83% rename from contrib/byacc/skeleton.c rename to contrib/byacc/yaccpar.c index 15b931a71..717d735de 100644 --- a/contrib/byacc/skeleton.c +++ b/contrib/byacc/yaccpar.c @@ -1,11 +1,11 @@ -/* $Id: skeleton.c,v 1.32 2013/03/04 23:19:39 tom Exp $ */ +/* This file generated automatically using + * @Id: skel2c,v 1.3 2014/04/06 19:48:04 tom Exp @ + */ + +/* @Id: yaccpar.skel,v 1.5 2014/04/07 21:51:00 tom Exp @ */ #include "defs.h" -/* The definition of yysccsid in the banner should be replaced with */ -/* a #pragma ident directive if the target C compiler supports */ -/* #pragma ident directives. */ -/* */ /* If the skeleton is changed, the banner should be changed so that */ /* the altered version can be easily distinguished from the original. */ /* */ @@ -17,7 +17,7 @@ const char *const banner[] = { "/* original parser id follows */", - "/* yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\" */", + "/* yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\" */", "/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */", "", "#define YYBYACC 1", @@ -31,7 +31,8 @@ const char *const banner[] = "#define yyclearin (yychar = YYEMPTY)", "#define yyerrok (yyerrflag = 0)", "#define YYRECOVERING() (yyerrflag != 0)", - "", + "#define YYENOMEM (-2)", + "#define YYEOF 0", 0 }; @@ -44,15 +45,15 @@ const char *const xdecls[] = const char *const tables[] = { - "extern short yylhs[];", - "extern short yylen[];", - "extern short yydefred[];", - "extern short yydgoto[];", - "extern short yysindex[];", - "extern short yyrindex[];", - "extern short yygindex[];", - "extern short yytable[];", - "extern short yycheck[];", + "extern YYINT yylhs[];", + "extern YYINT yylen[];", + "extern YYINT yydefred[];", + "extern YYINT yydgoto[];", + "extern YYINT yysindex[];", + "extern YYINT yyrindex[];", + "extern YYINT yygindex[];", + "extern YYINT yytable[];", + "extern YYINT yycheck[];", "", "#if YYDEBUG", "extern char *yyname[];", @@ -90,18 +91,18 @@ const char *const hdr_defs[] = "#ifdef YYMAXDEPTH", "#define YYSTACKSIZE YYMAXDEPTH", "#else", - "#define YYSTACKSIZE 500", - "#define YYMAXDEPTH 500", + "#define YYSTACKSIZE 10000", + "#define YYMAXDEPTH 10000", "#endif", "#endif", "", - "#define YYINITSTACKSIZE 500", + "#define YYINITSTACKSIZE 200", "", "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;", "} YYSTACKDATA;", @@ -142,27 +143,27 @@ const char *const body_1[] = "{", " int i;", " unsigned newsize;", - " short *newss;", + " YYINT *newss;", " YYSTYPE *newvs;", "", " if ((newsize = data->stacksize) == 0)", " newsize = YYINITSTACKSIZE;", " else if (newsize >= YYMAXDEPTH)", - " return -1;", + " return YYENOMEM;", " else if ((newsize *= 2) > YYMAXDEPTH)", " 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 -1;", + " return YYENOMEM;", "", " data->s_base = newss;", " data->s_mark = newss + i;", "", " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));", " if (newvs == 0)", - " return -1;", + " return YYENOMEM;", "", " data->l_base = newvs;", " data->l_mark = newvs + i;", @@ -217,7 +218,7 @@ const char *const body_2[] = " memset(&yystack, 0, sizeof(yystack));", "#endif", "", - " if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;", + " if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", " yystack.s_mark = yystack.s_base;", " yystack.l_mark = yystack.l_base;", " yystate = 0;", @@ -227,13 +228,11 @@ const char *const body_2[] = " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;", " if (yychar < 0)", " {", - " if ((yychar = YYLEX) < 0) yychar = 0;", + " if ((yychar = YYLEX) < 0) yychar = YYEOF;", "#if YYDEBUG", " if (yydebug)", " {", - " yys = 0;", - " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", - " if (!yys) yys = \"illegal-symbol\";", + " yys = yyname[YYTRANSLATE(yychar)];", " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", " YYPREFIX, yystate, yychar, yys);", " }", @@ -247,7 +246,7 @@ const char *const body_2[] = " printf(\"%sdebug: state %d, shifting to state %d\\n\",", " YYPREFIX, yystate, yytable[yyn]);", "#endif", - " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))", + " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)", " {", " goto yyoverflow;", " }", @@ -266,11 +265,7 @@ const char *const body_2[] = " }", " if (yyerrflag) goto yyinrecovery;", "", - 0 -}; - -const char *const body_3[] = -{ + " YYERROR_CALL(\"syntax error\");", "", " goto yyerrlab;", "", @@ -291,7 +286,7 @@ const char *const body_3[] = " 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))", + " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)", " {", " goto yyoverflow;", " }", @@ -304,8 +299,7 @@ const char *const body_3[] = " {", "#if YYDEBUG", " if (yydebug)", - " printf(\"%sdebug: error recovery discarding state %d\ -\\n\",", + " printf(\"%sdebug: error recovery discarding state %d\\n\",", " YYPREFIX, *yystack.s_mark);", "#endif", " if (yystack.s_mark <= yystack.s_base) goto yyabort;", @@ -316,15 +310,12 @@ const char *const body_3[] = " }", " else", " {", - " if (yychar == 0) goto yyabort;", + " if (yychar == YYEOF) goto yyabort;", "#if YYDEBUG", " if (yydebug)", " {", - " yys = 0;", - " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", - " if (!yys) yys = \"illegal-symbol\";", - " printf(\"%sdebug: state %d, error recovery discards token %d\ - (%s)\\n\",", + " yys = yyname[YYTRANSLATE(yychar)];", + " printf(\"%sdebug: state %d, error recovery discards token %d (%s)\\n\",", " YYPREFIX, yystate, yychar, yys);", " }", "#endif", @@ -367,19 +358,17 @@ const char *const trailer[] = " *++yystack.l_mark = yyval;", " if (yychar < 0)", " {", - " if ((yychar = YYLEX) < 0) yychar = 0;", + " if ((yychar = YYLEX) < 0) yychar = YYEOF;", "#if YYDEBUG", " if (yydebug)", " {", - " yys = 0;", - " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", - " if (!yys) yys = \"illegal-symbol\";", + " yys = yyname[YYTRANSLATE(yychar)];", " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", " YYPREFIX, YYFINAL, yychar, yys);", " }", "#endif", " }", - " if (yychar == 0) goto yyaccept;", + " if (yychar == YYEOF) goto yyaccept;", " goto yyloop;", " }", " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&", @@ -392,20 +381,16 @@ const char *const trailer[] = " 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))", + " 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;", " goto yyloop;", "", "yyoverflow:", - 0 -}; - -const char *const trailer_2[] = -{ + " YYERROR_CALL(\"yacc stack overflow\");", "", "yyabort:", " yyfreestack(&yystack);", @@ -421,19 +406,13 @@ const char *const trailer_2[] = void write_section(FILE * fp, const char *const section[]) { - int c; int i; const char *s; for (i = 0; (s = section[i]) != 0; ++i) { - while ((c = *s) != 0) - { - putc(c, fp); - ++s; - } if (fp == code_file) ++outline; - putc('\n', fp); + fprintf(fp, "%s\n", s); } } diff --git a/contrib/byacc/yaccpar.skel b/contrib/byacc/yaccpar.skel new file mode 100644 index 000000000..030cfa262 --- /dev/null +++ b/contrib/byacc/yaccpar.skel @@ -0,0 +1,353 @@ +/* $Id: yaccpar.skel,v 1.5 2014/04/07 21:51:00 tom Exp $ */ + +#include "defs.h" + +/* If the skeleton is changed, the banner should be changed so that */ +/* the altered version can be easily distinguished from the original. */ +/* */ +/* The #defines included with the banner are there because they are */ +/* useful in subsequent code. The macros #defined in the header or */ +/* the body either are not useful outside of semantic actions or */ +/* are conditional. */ + +%% banner +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +%% insert VERSION here + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +%% xdecls + +extern int YYPARSE_DECL(); +%% tables +extern YYINT yylhs[]; +extern YYINT yylen[]; +extern YYINT yydefred[]; +extern YYINT yydgoto[]; +extern YYINT yysindex[]; +extern YYINT yyrindex[]; +extern YYINT yygindex[]; +extern YYINT yytable[]; +extern YYINT yycheck[]; + +#if YYDEBUG +extern char *yyname[]; +extern char *yyrule[]; +#endif +%% global_vars + +int yydebug; +int yynerrs; +%% impure_vars + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +%% hdr_defs + +/* 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; +%% hdr_vars +/* variables for the parser stack */ +static YYSTACKDATA yystack; +%% body_vars + int yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; + + /* variables for the parser stack */ + YYSTACKDATA yystack; +%% body_1 + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* 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() +{ +%% body_2 + 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) == 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) + { + if ((yychar = YYLEX) < 0) yychar = YYEOF; +#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) == 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]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + YYERROR_CALL("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) == 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) + { + 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) + { +%% trailer + } + 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 = YYEOF; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) 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) == 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/usr.bin/yacc/Makefile b/usr.bin/yacc/Makefile index 25b63a737..c9c88140a 100644 --- a/usr.bin/yacc/Makefile +++ b/usr.bin/yacc/Makefile @@ -6,13 +6,11 @@ .PATH: ${.CURDIR}/../../contrib/byacc PROG= yacc -SRCS= closure.c error.c graph.c lalr.c lr0.c main.c mkpar.c output.c \ - reader.c skeleton.c symtab.c verbose.c warshall.c +SRCS= closure.c error.c graph.c lalr.c lr0.c main.c mkpar.c mstring.c output.c \ + reader.c yaccpar.c symtab.c verbose.c warshall.c CFLAGS+= -DMIXEDCASE_FILENAMES=1 \ - -DCC_HAS_PROTOS=1 \ -DHAVE_FCNTL_H=1 \ - -DHAVE_ATEXIT=1 \ -DHAVE_MKSTEMP=1 LINKS= ${BINDIR}/yacc ${BINDIR}/byacc -- 2.45.0